From bed0cd33ca32b95aed9d65891f97649a6f9d0069 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 18 Aug 2026 06:38:26 +0900 Subject: fix(process-executor): model commands as a CommandLine enum Commands were carried as `PhpMixed`, whose `String`/`List` variants do not tell a shell command line apart from an argv list at the type level. `Perforce::execute_command` and `Git::run_command` therefore funnelled string commands through `execute_args`, spawning `p4 set` or `git command` as a single argument instead of running it through a shell as PHP does; their tests were written against that shape. Introduce `CommandLine::{Shell, Args}` and use it for every `ProcessExecutor` entry point, the mock expectation queue and the `Git::run_command` callables. The unreachable "Invalid command type" branches disappear with it, and the affected tests go back to the string expectations the PHP suite uses. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/tests/util/perforce_test.rs | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'crates/shirabe/tests/util/perforce_test.rs') diff --git a/crates/shirabe/tests/util/perforce_test.rs b/crates/shirabe/tests/util/perforce_test.rs index 293e56d5..dfeae457 100644 --- a/crates/shirabe/tests/util/perforce_test.rs +++ b/crates/shirabe/tests/util/perforce_test.rs @@ -192,7 +192,7 @@ fn test_query_p4_user_with_user_already_set() { fn test_query_p4_user_with_user_set_in_p4_variables_with_windows_os() { let (process, _guard) = get_process_executor_mock( vec![cmd_full( - vec!["p4 set"], + "p4 set", 0, format!("P4USER=TEST_P4VARIABLE_USER{}", shirabe_php_shim::PHP_EOL), "", @@ -216,7 +216,7 @@ fn test_query_p4_user_with_user_set_in_p4_variables_with_windows_os() { fn test_query_p4_user_with_user_set_in_p4_variables_not_windows_os() { let (process, _guard) = get_process_executor_mock( vec![cmd_full( - vec!["echo $P4USER"], + "echo $P4USER", 0, format!("TEST_P4VARIABLE_USER{}", shirabe_php_shim::PHP_EOL), "", @@ -259,7 +259,7 @@ fn test_query_p4_user_stores_response_to_query_for_user_with_windows() { ProcessExecutor::escape("TEST_QUERY_USER") ); let (process, _guard) = get_process_executor_mock( - vec![cmd(vec!["p4 set"]), cmd(vec![expected_command.as_str()])], + vec![cmd("p4 set"), cmd(expected_command.as_str())], true, MockHandler::default(), ); @@ -280,10 +280,7 @@ fn test_query_p4_user_stores_response_to_query_for_user_without_windows() { ProcessExecutor::escape("TEST_QUERY_USER") ); let (process, _guard) = get_process_executor_mock( - vec![ - cmd(vec!["echo $P4USER"]), - cmd(vec![expected_command.as_str()]), - ], + vec![cmd("echo $P4USER"), cmd(expected_command.as_str())], true, MockHandler::default(), ); @@ -304,7 +301,7 @@ fn test_query_p4_user_escapes_injection_on_windows() { ProcessExecutor::escape("foo && calc.exe") ); let (process, _guard) = get_process_executor_mock( - vec![cmd(vec!["p4 set"]), cmd(vec![expected_command.as_str()])], + vec![cmd("p4 set"), cmd(expected_command.as_str())], true, MockHandler::default(), ); @@ -322,10 +319,7 @@ fn test_query_p4_user_escapes_injection_on_windows() { fn test_query_p4_user_escapes_injection_on_unix() { let expected_command = format!("export P4USER={}", ProcessExecutor::escape("foo; id")); let (process, _guard) = get_process_executor_mock( - vec![ - cmd(vec!["echo $P4USER"]), - cmd(vec![expected_command.as_str()]), - ], + vec![cmd("echo $P4USER"), cmd(expected_command.as_str())], true, MockHandler::default(), ); @@ -368,7 +362,7 @@ fn test_query_p4_password_with_password_already_set() { fn test_query_p4_password_with_password_set_in_p4_variables_with_windows_os() { let (process, _guard) = get_process_executor_mock( vec![cmd_full( - vec!["p4 set"], + "p4 set", 0, format!( "P4PASSWD=TEST_P4VARIABLE_PASSWORD{}", @@ -391,7 +385,7 @@ fn test_query_p4_password_with_password_set_in_p4_variables_with_windows_os() { fn test_query_p4_password_with_password_set_in_p4_variables_not_windows_os() { let (process, _guard) = get_process_executor_mock( vec![cmd_full( - vec!["echo $P4PASSWD"], + "echo $P4PASSWD", 0, format!("TEST_P4VARIABLE_PASSWORD{}", shirabe_php_shim::PHP_EOL), "", -- cgit v1.3.1-4-g156e