Skip to content

Commit

Permalink
adapt further tests for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
cre4ture committed Jan 14, 2024
1 parent 1b58ebf commit b995a0d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tests/by-util/test_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,13 @@ fn test_fail_change_directory() {
assert!(out.contains("env: cannot change directory to "));
}

Check failure on line 249 in tests/by-util/test_env.rs

View workflow job for this annotation

GitHub Actions / Style/format (ubuntu-latest, feat_os_unix)

ERROR: `cargo fmt`: style violation (file:'tests/by-util/test_env.rs', line:249; use `cargo fmt -- "tests/by-util/test_env.rs"`)

fn modify_newlines_according_platform(input: &str) -> String {
#[cfg(target_os="windows")]
{ input.replace("\n", "\r\n") }
#[cfg(not(target_os="windows"))]
{ input.into() }
}

#[test]
fn test_split_string_into_args_one_argument_no_quotes() {
let scene = TestScenario::new(util_name!());
Expand All @@ -257,7 +264,7 @@ fn test_split_string_into_args_one_argument_no_quotes() {
.arg("-S echo hello world")
.succeeds()
.stdout_move_str();
assert_eq!(out, "hello world\n");
assert_eq!(out, modify_newlines_according_platform("hello world\n"));
}

#[test]
Expand All @@ -269,7 +276,7 @@ fn test_split_string_into_args_one_argument() {
.arg("-S echo \"hello world\"")
.succeeds()
.stdout_move_str();
assert_eq!(out, "hello world\n");
assert_eq!(out, modify_newlines_according_platform("hello world\n"));
}

#[test]
Expand All @@ -281,7 +288,7 @@ fn test_split_string_into_args_s_escaping_challenge() {
.args(&[r#"-S echo "hello \"great\" world""#])

Check failure on line 288 in tests/by-util/test_env.rs

View workflow job for this annotation

GitHub Actions / Style/format (ubuntu-latest, feat_os_unix)

ERROR: `cargo fmt`: style violation (file:'tests/by-util/test_env.rs', line:288; use `cargo fmt -- "tests/by-util/test_env.rs"`)
.succeeds()
.stdout_move_str();
assert_eq!(out, "hello \"great\" world\n");
assert_eq!(out, modify_newlines_according_platform("hello \"great\" world\n"));
}

#[test]
Expand All @@ -295,6 +302,7 @@ fn test_split_string_into_args_s_escaped_c_not_allowed() {
);
}

#[cfg(not(target_os = "windows"))] // no printf available
#[test]
fn test_split_string_into_args_s_whitespace_handling() {
let scene = TestScenario::new(util_name!());
Expand All @@ -320,6 +328,7 @@ fn test_split_string_into_args_long_option_whitespace_handling() {
assert_eq!(out, "xAx\nxBx\n");
}

#[cfg(not(target_os = "windows"))] // no printf available
#[test]
fn test_split_string_into_args_debug_output_whitespace_handling() {
let scene = TestScenario::new(util_name!());
Expand Down

0 comments on commit b995a0d

Please sign in to comment.