sharkdp / bat

A cat(1) clone with wings.
Apache License 2.0
48.11k stars 1.2k forks source link

Unit test failed on Windows #2592

Open vidhyasasi opened 1 year ago

vidhyasasi commented 1 year ago

Cargo test failed on Windows machine What steps will reproduce the bug?

cargo test

What happens?

test result: FAILED. 101 passed; 9 failed; 2 ignored; 0 measured; 0 filtered out; finished in 3.65s

How did you install bat?

Build from source

bat version and environment bat 0.23.0 (876f5d4)

Windows version

10.0.20348 Build 20348

The failure message looks like:

failures:

---- alias_pager_disable_long_overrides_short stdout ---- thread 'alias_pager_disable_long_overrides_short' panicked at 'Unexpected stdout, failed var == "pager-output\n" ├── var: "hello world\n" └── var as str: hello world

command="C:\\Users\\Administrator\\Documents\\rust_artefacts\\packages\\bat\\target\\debug\\bat.exe" "--no-config" "-P" "--paging=always" "test.txt" code=0 stdout="hello world\n" stderr="" ', /rustc/90c541806f23a127002de5b4038be731ba1458ca\library\core\src\ops\function.rs:250:5 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

---- config_read_arguments_from_file stdout ---- thread 'config_read_arguments_from_file' panicked at 'Unexpected stdout, failed var == "dummy-pager-from-config\n" ├── var: "hello world\n" └── var as str: hello world

command="C:\\Users\\Administrator\\Documents\\rust_artefacts\\packages\\bat\\target\\debug\\bat.exe" "test.txt" code=0 stdout="hello world\n" stderr="" ', /rustc/90c541806f23a127002de5b4038be731ba1458ca\library\core\src\ops\function.rs:250:5

---- pager_arg_override_env_noconfig stdout ---- thread 'pager_arg_override_env_noconfig' panicked at 'Unexpected stdout, failed var == "pager-output\n" ├── var: "hello world\n" └── var as str: hello world

command="C:\\Users\\Administrator\\Documents\\rust_artefacts\\packages\\bat\\target\\debug\\bat.exe" "--no-config" "--pager=echo pager-output" "--paging=always" "test.txt" code=0 stdout="hello world\n" stderr="" ', /rustc/90c541806f23a127002de5b4038be731ba1458ca\library\core\src\ops\function.rs:250:5

---- pager_arg_override_env_withconfig stdout ---- thread 'pager_arg_override_env_withconfig' panicked at 'Unexpected stdout, failed var == "pager-output\n" ├── var: "hello world\n" └── var as str: hello world

command="C:\\Users\\Administrator\\Documents\\rust_artefacts\\packages\\bat\\target\\debug\\bat.exe" "--pager=echo pager-output" "--paging=always" "test.txt" code=0 stdout="hello world\n" stderr="" ', /rustc/90c541806f23a127002de5b4038be731ba1458ca\library\core\src\ops\function.rs:250:5

---- pager_basic stdout ---- thread 'pager_basic' panicked at 'Unexpected stdout, failed var == "pager-output\n" ├── var: "hello world\n" └── var as str: hello world

command="C:\\Users\\Administrator\\Documents\\rust_artefacts\\packages\\bat\\target\\debug\\bat.exe" "--no-config" "--paging=always" "test.txt" code=0 stdout="hello world\n" stderr="" ', /rustc/90c541806f23a127002de5b4038be731ba1458ca\library\core\src\ops\function.rs:250:5

---- pager_basic_arg stdout ---- thread 'pager_basic_arg' panicked at 'Unexpected stdout, failed var == "pager-output\n" ├── var: "hello world\n" └── var as str: hello world

command="C:\\Users\\Administrator\\Documents\\rust_artefacts\\packages\\bat\\target\\debug\\bat.exe" "--no-config" "--pager=echo pager-output" "--paging=always" "test.txt" code=0 stdout="hello world\n" stderr="" ', /rustc/90c541806f23a127002de5b4038be731ba1458ca\library\core\src\ops\function.rs:250:5

---- pager_env_bat_pager_override_config stdout ---- thread 'pager_env_bat_pager_override_config' panicked at 'Unexpected stdout, failed var == "pager-output\n" ├── var: "hello world\n" └── var as str: hello world

command="C:\\Users\\Administrator\\Documents\\rust_artefacts\\packages\\bat\\target\\debug\\bat.exe" "--paging=always" "test.txt" code=0 stdout="hello world\n" stderr="" ', /rustc/90c541806f23a127002de5b4038be731ba1458ca\library\core\src\ops\function.rs:250:5

---- pager_env_pager_nooverride_config stdout ---- thread 'pager_env_pager_nooverride_config' panicked at 'Unexpected stdout, failed var == "dummy-pager-from-config\n" ├── var: "hello world\n" └── var as str: hello world

command="C:\\Users\\Administrator\\Documents\\rust_artefacts\\packages\\bat\\target\\debug\\bat.exe" "--paging=always" "test.txt" code=0 stdout="hello world\n" stderr="" ', /rustc/90c541806f23a127002de5b4038be731ba1458ca\library\core\src\ops\function.rs:250:5

---- pager_overwrite stdout ---- thread 'pager_overwrite' panicked at 'Unexpected stdout, failed var == "pager-output\n" ├── var: "hello world\n" └── var as str: hello world

command="C:\\Users\\Administrator\\Documents\\rust_artefacts\\packages\\bat\\target\\debug\\bat.exe" "--no-config" "--paging=always" "test.txt" code=0 stdout="hello world\n" stderr="" ', /rustc/90c541806f23a127002de5b4038be731ba1458ca\library\core\src\ops\function.rs:250:5

failures: alias_pager_disable_long_overrides_short config_read_arguments_from_file pager_arg_override_env_noconfig pager_arg_override_env_withconfig pager_basic pager_basic_arg pager_env_bat_pager_override_config pager_env_pager_nooverride_config pager_overwrite

test result: FAILED. 101 passed; 9 failed; 2 ignored; 0 measured; 0 filtered out; finished in 3.65s

error: test failed, to rerun pass --test integration_tests

boyvanduuren commented 1 year ago

This is because of https://github.com/sharkdp/bat/blob/8676bbf97f2832ad2231e102ca9c9b7b72267fda/src/output.rs#L66 not resolving for echo in powershell, as it's an alias for Write-Output, which is a shell built-in.