Skip to content

Commit 3bd38f2

Browse files
authored
fix(tests): restrict 'cat' tests to unix environments. Fixes sharkdp#776 (sharkdp#777)
Tests using the 'cat' command are specific to unix-like environments and fail on unsupported platforms.
1 parent f6794c3 commit 3bd38f2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/integration_tests.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ use common::hyperfine;
33

44
use predicates::prelude::*;
55

6+
/// Platform-specific I/O utility.
7+
/// - On Unix-like systems, defaults to `cat`.
8+
/// - On Windows, uses `findstr` as an alternative.
9+
/// See: <https://superuser.com/questions/853580/real-windows-equivalent-to-cat-stdin>
10+
const STDIN_READ_COMMAND: &str = if cfg!(windows) { "findstr x*" } else { "cat" };
11+
612
pub fn hyperfine_debug() -> assert_cmd::Command {
713
let mut cmd = hyperfine();
814
cmd.arg("--debug-mode");
@@ -306,7 +312,7 @@ fn can_pass_input_to_command_from_a_file() {
306312
.arg("--runs=1")
307313
.arg("--input=example_input_file.txt")
308314
.arg("--show-output")
309-
.arg("cat")
315+
.arg(STDIN_READ_COMMAND)
310316
.assert()
311317
.success()
312318
.stdout(predicate::str::contains("This text is part of a file"));
@@ -318,7 +324,7 @@ fn fails_if_invalid_stdin_data_file_provided() {
318324
.arg("--runs=1")
319325
.arg("--input=example_non_existent_file.txt")
320326
.arg("--show-output")
321-
.arg("cat")
327+
.arg(STDIN_READ_COMMAND)
322328
.assert()
323329
.failure()
324330
.stderr(predicate::str::contains(

0 commit comments

Comments
 (0)