From 39d400e83d35aa0afbbf46fda9d9255761aaf33e Mon Sep 17 00:00:00 2001 From: Ritvik-UX Date: Mon, 25 Nov 2024 03:23:03 +0530 Subject: [PATCH 1/2] fix(tests): restrict 'cat' tests to unix environments Tests using the 'cat' command are specific to unix-like environments and fail on unsupported platforms. --- tests/integration_tests.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 873f40052..7035b0a80 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -300,6 +300,7 @@ fn runs_commands_using_user_defined_shell() { ); } +#[cfg(unix)] #[test] fn can_pass_input_to_command_from_a_file() { hyperfine() @@ -312,6 +313,7 @@ fn can_pass_input_to_command_from_a_file() { .stdout(predicate::str::contains("This text is part of a file")); } +#[cfg(unix)] #[test] fn fails_if_invalid_stdin_data_file_provided() { hyperfine() From 54e81a95aa7285f15b7fb52c27c17ab16a06910f Mon Sep 17 00:00:00 2001 From: Ritvik-UX Date: Mon, 2 Dec 2024 21:05:58 +0530 Subject: [PATCH 2/2] fix(tests): 'cat' equivalent for windows compatibility --- tests/integration_tests.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 7035b0a80..bd9ba5898 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -313,6 +313,19 @@ fn can_pass_input_to_command_from_a_file() { .stdout(predicate::str::contains("This text is part of a file")); } +#[cfg(windows)] +#[test] +fn can_pass_input_to_command_from_a_file() { + hyperfine() + .arg("--runs=1") + .arg("--input=example_input_file.txt") + .arg("--show-output") + .arg("type example_input_file.txt") + .assert() + .success() + .stdout(predicate::str::contains("This text is part of a file")); +} + #[cfg(unix)] #[test] fn fails_if_invalid_stdin_data_file_provided() { @@ -328,6 +341,21 @@ fn fails_if_invalid_stdin_data_file_provided() { )); } +#[cfg(windows)] +#[test] +fn fails_if_invalid_stdin_data_file_provided() { + hyperfine() + .arg("--runs=1") + .arg("--input=example_non_existent_file.txt") + .arg("--show-output") + .arg("type example_non_existent_file.txt") + .assert() + .failure() + .stderr(predicate::str::contains( + "The file 'example_non_existent_file.txt' specified as '--input' does not exist", + )); +} + #[test] fn returns_mean_time_in_correct_unit() { hyperfine_debug()