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

Tests using the 'cat' command are specific
to unix-like environments and
fail on unsupported platforms.
This commit is contained in:
Ritvik authored and GitHub committed 2025-01-04 22:27:16 +01:00
1 parent f6794c313c
commit 3bd38f275e
1 file changed
+8 -2
+8 -2
View File
@@ -3,6 +3,12 @@ use common::hyperfine;
use predicates::prelude::*;
/// Platform-specific I/O utility.
/// - On Unix-like systems, defaults to `cat`.
/// - On Windows, uses `findstr` as an alternative.
/// See: <https://superuser.com/questions/853580/real-windows-equivalent-to-cat-stdin>
const STDIN_READ_COMMAND: &str = if cfg!(windows) { "findstr x*" } else { "cat" };
pub fn hyperfine_debug() -> assert_cmd::Command {
let mut cmd = hyperfine();
cmd.arg("--debug-mode");
@@ -306,7 +312,7 @@ fn can_pass_input_to_command_from_a_file() {
.arg("--runs=1")
.arg("--input=example_input_file.txt")
.arg("--show-output")
.arg("cat")
.arg(STDIN_READ_COMMAND)
.assert()
.success()
.stdout(predicate::str::contains("This text is part of a file"));
@@ -318,7 +324,7 @@ fn fails_if_invalid_stdin_data_file_provided() {
.arg("--runs=1")
.arg("--input=example_non_existent_file.txt")
.arg("--show-output")
.arg("cat")
.arg(STDIN_READ_COMMAND)
.assert()
.failure()
.stderr(predicate::str::contains(