mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-15 04:14:15 +01:00
Add regression test for detected syntax differing for stdin and files
This commit is contained in:
parent
157b8dd848
commit
82981c9663
5
tests/examples/regression_tests/issue_985.js
Normal file
5
tests/examples/regression_tests/issue_985.js
Normal file
@ -0,0 +1,5 @@
|
||||
// This test should be considered a failure if the detected syntax differs between the following two commands:
|
||||
/*
|
||||
# bat --map-syntax '*.js:Markdown' --file-name 'issue_985.js' < issue_985.js
|
||||
# bat --map-syntax '*.js:Markdown' --file-name 'issue_985.js' issue_985.js
|
||||
*/
|
@ -1,4 +1,8 @@
|
||||
use assert_cmd::Command;
|
||||
use std::path::Path;
|
||||
use std::str::from_utf8;
|
||||
|
||||
const EXAMPLES_DIR: &str = "tests/examples";
|
||||
|
||||
fn bat_with_config() -> Command {
|
||||
let mut cmd = Command::cargo_bin("bat").unwrap();
|
||||
@ -670,3 +674,38 @@ fn do_not_panic_regression_tests() {
|
||||
.success();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn do_not_detect_different_syntax_for_stdin_and_files() {
|
||||
let file = "regression_tests/issue_985.js";
|
||||
|
||||
let output_for_file = bat()
|
||||
.arg("--color=always")
|
||||
.arg("--map-syntax=*.js:Markdown")
|
||||
.arg(&format!("--file-name={}", file))
|
||||
.arg("--style=plain")
|
||||
.arg(file)
|
||||
.assert()
|
||||
.success()
|
||||
.get_output()
|
||||
.stdout
|
||||
.clone();
|
||||
|
||||
let output_for_stdin = bat()
|
||||
.arg("--color=always")
|
||||
.arg("--map-syntax=*.js:Markdown")
|
||||
.arg("--style=plain")
|
||||
.arg(&format!("--file-name={}", file))
|
||||
.pipe_stdin(Path::new(EXAMPLES_DIR).join(file))
|
||||
.unwrap()
|
||||
.assert()
|
||||
.success()
|
||||
.get_output()
|
||||
.stdout
|
||||
.clone();
|
||||
|
||||
assert_eq!(
|
||||
from_utf8(&output_for_file).unwrap(),
|
||||
from_utf8(&output_for_stdin).unwrap()
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user