From 67a0220dc4c4ff6f79a24771fb175baec22bc6b0 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 5 Oct 2023 13:37:25 +0200 Subject: [PATCH] fix gix-command tests on windows It seems windows now has a windows-unspecific `echo` program and one can't really rely on it producing windows style newlines. Now we use printf which is more standard and can be used to validate multiple arguments as well. --- gix-command/tests/command.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/gix-command/tests/command.rs b/gix-command/tests/command.rs index e2faa7fc929..606066da131 100644 --- a/gix-command/tests/command.rs +++ b/gix-command/tests/command.rs @@ -82,32 +82,26 @@ mod spawn { #[test] fn sh_shell_specific_script_code_with_single_extra_arg() -> crate::Result { - let out = gix_command::prepare("echo") + let out = gix_command::prepare("printf") .with_shell() .arg("1") .spawn()? .wait_with_output()?; assert!(out.status.success()); - #[cfg(not(windows))] - assert_eq!(out.stdout.as_bstr(), "1\n"); - #[cfg(windows)] - assert_eq!(out.stdout.as_bstr(), "1\r\n"); + assert_eq!(out.stdout.as_bstr(), "1"); Ok(()) } #[test] fn sh_shell_specific_script_code_with_multiple_extra_args() -> crate::Result { - let out = gix_command::prepare("echo") + let out = gix_command::prepare("printf") .with_shell() - .arg("1") - .arg("2") + .arg("%s") + .arg("arg") .spawn()? .wait_with_output()?; assert!(out.status.success()); - #[cfg(not(windows))] - assert_eq!(out.stdout.as_bstr(), "1 2\n"); - #[cfg(windows)] - assert_eq!(out.stdout.as_bstr(), "1 2\r\n"); + assert_eq!(out.stdout.as_bstr(), "arg"); Ok(()) } }