aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-07-19 15:20:26 +0900
committernsfisis <nsfisis@gmail.com>2026-07-19 17:53:42 +0900
commit82cd8e8051ef791b9224916a5e2060ad38c1f82b (patch)
tree32c1428f354c2f43df1819c5c5ee74dfdd6c403f /crates/shirabe
parenta3334ee267d3e905646bdb49c2edc8774ac8d966 (diff)
downloadphp-shirabe-82cd8e8051ef791b9224916a5e2060ad38c1f82b.tar.gz
php-shirabe-82cd8e8051ef791b9224916a5e2060ad38c1f82b.tar.zst
php-shirabe-82cd8e8051ef791b9224916a5e2060ad38c1f82b.zip
fix(update-command): un-ignore test_update by fixing 3 real bugs
test_update was skipped for a stale reason; running it uncovered three distinct bugs it was actually catching: - ApplicationTester::run never restored SHELL_VERBOSITY after Application::configureIO mutates it, so one dataset's -vv verbosity leaked into later runs sharing the process (Symfony's tester restores it in a finally block; the port dropped that). - Installer::do_install built its RepositorySet with a hardcoded empty temporary_constraints map instead of self.temporary_constraints, so --with never actually constrained the resolver. - BumpCommand was missing a <warning> tag pair around one of its output lines.
Diffstat (limited to 'crates/shirabe')
-rw-r--r--crates/shirabe/src/command/bump_command.rs2
-rw-r--r--crates/shirabe/src/installer.rs3
-rw-r--r--crates/shirabe/tests/command/update_command_test.rs3
-rw-r--r--crates/shirabe/tests/common/test_case.rs67
4 files changed, 55 insertions, 20 deletions
diff --git a/crates/shirabe/src/command/bump_command.rs b/crates/shirabe/src/command/bump_command.rs
index 8f27fcb8..4b09f14c 100644
--- a/crates/shirabe/src/command/bump_command.rs
+++ b/crates/shirabe/src/command/bump_command.rs
@@ -146,7 +146,7 @@ impl BumpCommand {
.is_some_and(|m| m.contains_key("type"))
{
io.write_error3(
- "If your package is not a library, you can explicitly specify the \"type\" by using \"composer config type project\".",
+ "<warning>If your package is not a library, you can explicitly specify the \"type\" by using \"composer config type project\".</warning>",
true,
io_interface::NORMAL,
);
diff --git a/crates/shirabe/src/installer.rs b/crates/shirabe/src/installer.rs
index 068b85c3..6d943ea7 100644
--- a/crates/shirabe/src/installer.rs
+++ b/crates/shirabe/src/installer.rs
@@ -1436,14 +1436,13 @@ impl Installer {
alias_normalized: alias.get("alias_normalized").cloned().unwrap_or_default(),
})
.collect();
- let temporary_constraints: IndexMap<String, AnyConstraint> = IndexMap::new();
let mut repository_set = RepositorySet::new(
&minimum_stability,
stability_flags,
root_aliases_input,
self.package.get_references().clone(),
root_requires,
- temporary_constraints,
+ self.temporary_constraints.clone(),
);
repository_set.add_repository(crate::repository::RepositoryInterfaceHandle::new(
RootPackageRepository::new(self.fixed_root_package.clone()),
diff --git a/crates/shirabe/tests/command/update_command_test.rs b/crates/shirabe/tests/command/update_command_test.rs
index 866755bf..ed17d80e 100644
--- a/crates/shirabe/tests/command/update_command_test.rs
+++ b/crates/shirabe/tests/command/update_command_test.rs
@@ -235,7 +235,6 @@ Your requirements could not be resolved to an installable set of packages.
#[test]
#[serial]
-#[ignore = "regex porting: a Preg pattern starting with \"^array \" fails to compile in shirabe-php-shim preg.rs (\"unterminated regex pattern\"); unrelated to InputDefinition"]
fn test_update() {
for (label, composer_json, command, expected, create_lock) in provide_updates() {
let _tear_down = init_temp_composer(Some(&composer_json), None, None, true);
@@ -260,7 +259,6 @@ fn test_update() {
#[test]
#[serial]
-#[ignore = "resolver does not emit the temporary-update-constraint conflict; it performs the upgrade instead of reporting \"conflicts with your temporary update constraint\""]
fn test_update_with_patch_only() {
let composer_json = serde_json::json!({
"repositories": { "packages": { "type": "package", "package": [
@@ -604,7 +602,6 @@ fn test_no_security_blocking_allows_insecure_packages() {
#[test]
#[serial]
-#[ignore = "solver error \"Fixed package __root__ 1.0.0+no-version-set was not added to solver pool.\" on the no-lockfile bump path (resolver pool construction)"]
fn test_bump_after_update_without_lockfile() {
let composer_json = serde_json::json!({
"repositories": { "packages": { "type": "package", "package": [
diff --git a/crates/shirabe/tests/common/test_case.rs b/crates/shirabe/tests/common/test_case.rs
index 91d890a9..2b94bbe1 100644
--- a/crates/shirabe/tests/common/test_case.rs
+++ b/crates/shirabe/tests/common/test_case.rs
@@ -317,24 +317,63 @@ impl ApplicationTester {
input: Vec<(PhpMixed, PhpMixed)>,
options: RunOptions,
) -> anyhow::Result<i32> {
- let mut array_input = ArrayInput::new(input, None)?;
- if let Some(interactive) = options.interactive {
- array_input.set_interactive(interactive);
- }
- if !self.inputs.is_empty() {
- array_input.set_stream(Self::create_stream(&self.inputs));
- }
+ let prev_shell_verbosity = shirabe_php_shim::getenv("SHELL_VERBOSITY");
+
+ let result = (|| -> anyhow::Result<i32> {
+ let mut array_input = ArrayInput::new(input, None)?;
+ if let Some(interactive) = options.interactive {
+ array_input.set_interactive(interactive);
+ }
+ if !self.inputs.is_empty() {
+ array_input.set_stream(Self::create_stream(&self.inputs));
+ }
+
+ self.init_output(&options);
- self.init_output(&options);
+ let input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>> =
+ std::rc::Rc::new(std::cell::RefCell::new(array_input));
+ let output = self.output.clone().expect("init_output initializes output");
- let input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>> =
- std::rc::Rc::new(std::cell::RefCell::new(array_input));
- let output = self.output.clone().expect("init_output initializes output");
+ let status_code = self.application.run(Some(input), Some(output))?;
+ self.status_code = Some(status_code);
- let status_code = self.application.run(Some(input), Some(output))?;
- self.status_code = Some(status_code);
+ Ok(status_code)
+ })();
+
+ // ref: Symfony\Component\Console\Tester\ApplicationTester::run's `finally` block.
+ // Application::configureIO mutates the real SHELL_VERBOSITY env var (and the $_ENV/$_SERVER
+ // superglobal shims), so it must be restored here or one test's verbosity leaks into the
+ // next `run()` call sharing this process.
+ match &prev_shell_verbosity {
+ None => {
+ if shirabe_php_shim::function_exists("putenv") {
+ unsafe { shirabe_php_shim::putenv_clear("SHELL_VERBOSITY") };
+ }
+ shirabe_php_shim::PHP_ENV
+ .lock()
+ .unwrap()
+ .clear("SHELL_VERBOSITY");
+ shirabe_php_shim::PHP_SERVER
+ .lock()
+ .unwrap()
+ .clear("SHELL_VERBOSITY");
+ }
+ Some(prev) => {
+ if shirabe_php_shim::function_exists("putenv") {
+ unsafe { shirabe_php_shim::putenv("SHELL_VERBOSITY", prev) };
+ }
+ shirabe_php_shim::PHP_ENV
+ .lock()
+ .unwrap()
+ .put("SHELL_VERBOSITY".into(), prev.clone());
+ shirabe_php_shim::PHP_SERVER
+ .lock()
+ .unwrap()
+ .put("SHELL_VERBOSITY".into(), prev.clone());
+ }
+ }
- Ok(status_code)
+ result
}
fn init_output(&mut self, options: &RunOptions) {