From 3bd38f275e4d3cb35794e3869e35d6947cbbf182 Mon Sep 17 00:00:00 2001 From: Ritvik Date: Sun, 5 Jan 2025 02:57:16 +0530 Subject: [PATCH] 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. --- tests/integration_tests.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 873f400..4efe20c 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -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: +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(