From 0e451d050e12343353a8976eb6bef2c6f8e54851 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Sun, 16 Feb 2025 22:04:56 -0500 Subject: [PATCH 1/2] Fix and enable disallow_shell test on Windows The `disallow_shell` test case for `gix-command` has two parts. The first part runs a command that would fail if not really run in a shell, mostly to verify that the second part of the test is robust enough. The second part actually tests the `Prepare::without_shell` method. While neither part should be made any less robust, only the first part had failed on Windows, and the reason was (or had become) only that it would not really run in a shell, due to being eligible for manual argument splitting and `allow_manual_arg_splitting` being `true` by default on Windows. Therefore, this modifies the first part to use a method that sets `allow_manual_arg_splitting` to `false`. This is sufficient to make the test pass on Windows, so this also enables it on all platforms. --- gix-command/tests/command.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gix-command/tests/command.rs b/gix-command/tests/command.rs index deecb039c84..6cb0a2803c0 100644 --- a/gix-command/tests/command.rs +++ b/gix-command/tests/command.rs @@ -459,10 +459,9 @@ mod spawn { } #[test] - #[cfg(unix)] fn disallow_shell() -> crate::Result { let out = gix_command::prepare("PATH= echo hi") - .command_may_be_shell_script() + .command_may_be_shell_script_disallow_manual_argument_splitting() .spawn()? .wait_with_output()?; assert_eq!(out.stdout.as_bstr(), "hi\n"); From 4fc1092dee396dbb0b8f5f6df07fee127965ee47 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Sun, 16 Feb 2025 22:48:31 -0500 Subject: [PATCH 2/2] Test environment_variables_are_passed_one_by_one on Windows This enables the `environment_variables_are_passed_one_by_one` test for `gix-command` on Windows. It was marked to run on Unix-like systems only. But it runs and passes on Windows, requiring no changes. (Possibly it hadn't passed at the time it was introduced.) The `command_may_be_shell_script` call is sufficient even though it does not disable manual argument splitting, because the command used in this test contains `$` (to expand variables in the shell) and is thus already ineligible for manual argument splitting. --- gix-command/tests/command.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/gix-command/tests/command.rs b/gix-command/tests/command.rs index 6cb0a2803c0..118c593d45a 100644 --- a/gix-command/tests/command.rs +++ b/gix-command/tests/command.rs @@ -446,7 +446,6 @@ mod spawn { use bstr::ByteSlice; #[test] - #[cfg(unix)] fn environment_variables_are_passed_one_by_one() -> crate::Result { let out = gix_command::prepare("echo $FIRST $SECOND") .env("FIRST", "first")