Skip to content

Commit

Permalink
fix gix-command tests on windows
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Byron committed Oct 5, 2023
1 parent f929d42 commit 67a0220
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions gix-command/tests/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
}
Expand Down

0 comments on commit 67a0220

Please sign in to comment.