Skip to content

Commit

Permalink
fix(tests): restrict 'cat' tests to unix environments. Fixes #776 (#777)
Browse files Browse the repository at this point in the history
Tests using the 'cat' command are specific
to unix-like environments and
fail on unsupported platforms.
  • Loading branch information
ritvikos authored Jan 4, 2025
1 parent f6794c3 commit 3bd38f2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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"));
Expand All @@ -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(
Expand Down

0 comments on commit 3bd38f2

Please sign in to comment.