Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tests): restrict 'cat' tests to unix environments. Fixes #776 #777

Merged
merged 7 commits into from
Jan 4, 2025
30 changes: 30 additions & 0 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ fn runs_commands_using_user_defined_shell() {
);
}

#[cfg(unix)]
#[test]
fn can_pass_input_to_command_from_a_file() {
hyperfine()
Expand All @@ -312,6 +313,20 @@ 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")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not testing the right thing, I believe? The cat test above on Linux makes sure that we can pipe input from example_input_file.txt into the benchmarked command. But this looks to me like you ignore that and simply output the contents if example_input_file.txt using type.

.assert()
.success()
.stdout(predicate::str::contains("This text is part of a file"));
}

#[cfg(unix)]
#[test]
fn fails_if_invalid_stdin_data_file_provided() {
hyperfine()
Expand All @@ -326,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()
Expand Down
Loading