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) --- .../shirabe/tests/common/process_executor_mock.rs | 33 ++++++++-------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'crates/shirabe/tests/common') diff --git a/crates/shirabe/tests/common/process_executor_mock.rs b/crates/shirabe/tests/common/process_executor_mock.rs index 33d9dfba..eb39b9c6 100644 --- a/crates/shirabe/tests/common/process_executor_mock.rs +++ b/crates/shirabe/tests/common/process_executor_mock.rs @@ -1,7 +1,6 @@ //! ref: composer/tests/Composer/Test/Mock/ProcessExecutorMock.php -use shirabe::util::process_executor::{MockExpectation, MockHandler, ProcessExecutor}; -use shirabe_php_shim::PhpMixed; +use shirabe::util::process_executor::{CommandLine, MockExpectation, MockHandler, ProcessExecutor}; // A command expectation as written in the PHP tests: either a bare command // (`'git command'` / `['git', '--version']`) or the full @@ -29,44 +28,36 @@ pub fn cmd_full( // string args. Comparison against the executed command is exact (PHP `===`), so // the form here must match the form the code under test passes to `execute`. pub trait IntoMockCmd { - fn into_mock_cmd(self) -> PhpMixed; + fn into_mock_cmd(self) -> CommandLine; } impl IntoMockCmd for &str { - fn into_mock_cmd(self) -> PhpMixed { - PhpMixed::String(self.to_string()) + fn into_mock_cmd(self) -> CommandLine { + CommandLine::Shell(self.to_string()) } } impl IntoMockCmd for String { - fn into_mock_cmd(self) -> PhpMixed { - PhpMixed::String(self) + fn into_mock_cmd(self) -> CommandLine { + CommandLine::Shell(self) } } impl IntoMockCmd for Vec<&str> { - fn into_mock_cmd(self) -> PhpMixed { - PhpMixed::List( - self.into_iter() - .map(|s| PhpMixed::String(s.to_string())) - .collect(), - ) + fn into_mock_cmd(self) -> CommandLine { + CommandLine::Args(self.into_iter().map(|s| s.to_string()).collect()) } } impl IntoMockCmd for Vec { - fn into_mock_cmd(self) -> PhpMixed { - PhpMixed::List(self.into_iter().map(PhpMixed::String).collect()) + fn into_mock_cmd(self) -> CommandLine { + CommandLine::Args(self) } } impl IntoMockCmd for [&str; N] { - fn into_mock_cmd(self) -> PhpMixed { - PhpMixed::List( - self.iter() - .map(|s| PhpMixed::String(s.to_string())) - .collect(), - ) + fn into_mock_cmd(self) -> CommandLine { + CommandLine::Args(self.iter().map(|s| s.to_string()).collect()) } } -- cgit v1.3.1-4-g156e