aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-22 18:05:06 +0900
committernsfisis <nsfisis@gmail.com>2026-08-22 18:05:06 +0900
commit62c206032a09f6b19777c1b3bc6f4ca3da71cdc3 (patch)
tree0b19ca9d377cec842fc10e6a7acb46420cd5bb61 /crates/shirabe/tests
parentec5f3292ac324789298c3a12972f8f78b688ca24 (diff)
downloadphp-shirabe-62c206032a09f6b19777c1b3bc6f4ca3da71cdc3.tar.gz
php-shirabe-62c206032a09f6b19777c1b3bc6f4ca3da71cdc3.tar.zst
php-shirabe-62c206032a09f6b19777c1b3bc6f4ca3da71cdc3.zip
fix(event-dispatcher): run COMPOSER_BINARY without a PHP interpreter
`@composer <args>` and a bare `composer <args>` script both re-enter the binary running the script, taken from COMPOSER_BINARY. That path used to be prefixed with the PHP interpreter command, which produced `php <shirabe path> install` and could not run: Shirabe ships as a native executable, not a phar. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests')
-rw-r--r--crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs48
1 files changed, 48 insertions, 0 deletions
diff --git a/crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs b/crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs
index 90df0624..2c74768a 100644
--- a/crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs
+++ b/crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs
@@ -36,6 +36,7 @@ use shirabe_symfony_console::output::output_interface;
fn tear_down() {
Platform::clear_env("COMPOSER_SKIP_SCRIPTS");
Platform::clear_env("PHP_BINARY");
+ Platform::clear_env("COMPOSER_BINARY");
}
struct TearDown;
@@ -977,3 +978,50 @@ fn test_dispatcher_outputs_error_on_failed_command() {
);
assert_eq!(expected, io.borrow().get_output());
}
+
+/// Both `@composer <args>` and a bare `composer <args>` script re-enter the binary that is running
+/// the script, taken from COMPOSER_BINARY. That binary is a native executable, so it is run
+/// directly rather than being passed to a PHP interpreter.
+#[test]
+#[serial]
+fn test_dispatcher_runs_composer_scripts_through_the_running_binary() {
+ let _tear_down = TearDown;
+
+ Platform::put_env("COMPOSER_BINARY", "/path/to/shirabe");
+ let binary = ProcessExecutor::escape("/path/to/shirabe");
+
+ let (process, _process_guard) = get_process_executor_mock(
+ vec![
+ cmd(format!("{} install --no-dev", binary)),
+ cmd(format!("{} update", binary)),
+ ],
+ true,
+ MockHandler::default(),
+ );
+
+ let composer = create_composer_instance();
+ let io = buffer_io_verbose();
+ let io_dyn: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = io.clone();
+
+ let mut dispatcher = dispatcher_with_listeners(
+ &composer,
+ io_dyn,
+ process,
+ listeners_const(vec!["@composer install --no-dev", "composer update"]),
+ );
+
+ dispatcher
+ .dispatch_script(
+ ScriptEvents::POST_INSTALL_CMD,
+ false,
+ vec![],
+ IndexMap::new(),
+ )
+ .unwrap();
+
+ let expected = format!(
+ "> post-install-cmd: @composer install --no-dev{eol}> post-install-cmd: composer update{eol}",
+ eol = PHP_EOL,
+ );
+ assert_eq!(expected, io.borrow().get_output());
+}