1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-10-30 06:33:59 +00:00

Modified snapshot tests to support tab expansion.

This changes how the files are named (to allow for snapshots that aren't
directly related to the --style argument) and fixes the
generate_snapshots.py script to work with the latest version of bat.

Three new tests are also introduced:
- tabs_4 - Tab expansion with a width of 4.
- tabs_8 - Tab expansion with a width of 8.
- tabs_passthrough - No tab expansion.
This commit is contained in:
eth-p
2018-09-10 19:19:43 -07:00
parent b23ff24ebc
commit 9159341714
5 changed files with 68 additions and 28 deletions

View File

@@ -38,13 +38,14 @@ impl BatTester {
BatTester { temp_dir, exe }
}
pub fn test_snapshot(&self, style: &str) {
pub fn test_snapshot(&self, name: &str, style: &str, tab_width: u32) {
let output = Command::new(&self.exe)
.current_dir(self.temp_dir.path())
.args(&[
"sample.rs",
"--decorations=always",
"--terminal-width=80",
&format!("--tabs={}", tab_width),
&format!("--style={}", style),
]).output()
.expect("bat failed");
@@ -55,7 +56,7 @@ impl BatTester {
.replace("tests/snapshots/", "");
let mut expected = String::new();
let mut file = File::open(format!("tests/snapshots/output/{}.snapshot.txt", style))
let mut file = File::open(format!("tests/snapshots/output/{}.snapshot.txt", name))
.expect("snapshot file missing");
file.read_to_string(&mut expected)
.expect("could not read snapshot file");