1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-03 20:02:28 +01:00

Add regression test for detected syntax differing for stdin and files

This commit is contained in:
Ethan P
2020-05-13 02:51:49 -07:00
parent 157b8dd848
commit 82981c9663
2 changed files with 44 additions and 0 deletions

View File

@@ -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()
);
}