1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-10-20 10:43:56 +01:00

rewrite 6 snapshot tests as integration test

This commit is contained in:
Lawrence Chou
2018-10-15 23:22:23 +08:00
committed by David Peter
parent afc5aacb28
commit 58198d0700
8 changed files with 124 additions and 253 deletions

View File

@@ -1,10 +1,7 @@
extern crate assert_cmd;
mod tester;
use assert_cmd::prelude::*;
use std::process::Command;
use tester::BatTester;
fn bat() -> Command {
let mut cmd = Command::main_binary().unwrap();
@@ -15,10 +12,6 @@ fn bat() -> Command {
cmd
}
fn tester() -> BatTester {
BatTester::new()
}
#[test]
fn basic() {
bat()
@@ -105,32 +98,140 @@ fn line_range_last_3() {
#[test]
fn tabs_passthrough_wrapped() {
tester().test_snapshot("tabs_passthrough_wrapped", "full", 0, true);
bat()
.arg("tabs.txt")
.arg("--tabs=0")
.arg("--wrap=character")
.arg("--style=plain")
.arg("--decorations=always")
.assert()
.success()
.stdout("
1 2 3 4
1 ?
22 ?
333 ?
4444 ?
55555 ?
666666 ?
7777777 ?
88888888 ?
");
}
#[test]
fn tabs_4_wrapped() {
tester().test_snapshot("tabs_4_wrapped", "full", 4, true);
bat()
.arg("tabs.txt")
.arg("--tabs=4")
.arg("--wrap=character")
.arg("--style=plain")
.arg("--decorations=always")
.assert()
.success()
.stdout("
1 2 3 4
1 ?
22 ?
333 ?
4444 ?
55555 ?
666666 ?
7777777 ?
88888888 ?
");
}
#[test]
fn tabs_8_wrapped() {
tester().test_snapshot("tabs_8_wrapped", "full", 8, true);
bat()
.arg("tabs.txt")
.arg("--tabs=8")
.arg("--wrap=character")
.arg("--style=plain")
.arg("--decorations=always")
.assert()
.success()
.stdout("
1 2 3 4
1 ?
22 ?
333 ?
4444 ?
55555 ?
666666 ?
7777777 ?
88888888 ?
");
}
#[test]
fn tabs_passthrough() {
tester().test_snapshot("tabs_passthrough", "full", 0, false);
bat()
.arg("tabs.txt")
.arg("--tabs=0")
.arg("--wrap=never")
.arg("--style=plain")
.arg("--decorations=always")
.assert()
.success()
.stdout("
1 2 3 4
1 ?
22 ?
333 ?
4444 ?
55555 ?
666666 ?
7777777 ?
88888888 ?
");
}
#[test]
fn tabs_4() {
tester().test_snapshot("tabs_4", "full", 4, false);
bat()
.arg("tabs.txt")
.arg("--tabs=4")
.arg("--wrap=never")
.arg("--style=plain")
.arg("--decorations=always")
.assert()
.success()
.stdout("
1 2 3 4
1 ?
22 ?
333 ?
4444 ?
55555 ?
666666 ?
7777777 ?
88888888 ?
");
}
#[test]
fn tabs_8() {
tester().test_snapshot("tabs_8", "full", 8, false);
bat()
.arg("tabs.txt")
.arg("--tabs=8")
.arg("--wrap=never")
.arg("--style=plain")
.arg("--decorations=always")
.assert()
.success()
.stdout("
1 2 3 4
1 ?
22 ?
333 ?
4444 ?
55555 ?
666666 ?
7777777 ?
88888888 ?
");
}
#[test]