mirror of
https://github.com/sharkdp/bat.git
synced 2025-01-05 13:18:53 +01:00
Added three new snapshot tests for --tabs and --wrap.
This commit is contained in:
parent
d90797f8e9
commit
c1e1f753cf
@ -15,9 +15,12 @@ def generate_snapshots():
|
|||||||
for style in collective_styles:
|
for style in collective_styles:
|
||||||
generate_style_snapshot(style)
|
generate_style_snapshot(style)
|
||||||
|
|
||||||
generate_snapshot("tabs_passthrough", "--tabs=0 --style=full")
|
generate_snapshot("tabs_passthrough", "--tabs=0 --style=full --wrap=never")
|
||||||
generate_snapshot("tabs_4", "--tabs=4 --style=full")
|
generate_snapshot("tabs_passthrough_wrapped", "--tabs=0 --style=full --wrap=character")
|
||||||
generate_snapshot("tabs_8", "--tabs=8 --style=full")
|
generate_snapshot("tabs_4", "--tabs=4 --style=full --wrap=never")
|
||||||
|
generate_snapshot("tabs_4_wrapped", "--tabs=4 --style=full --wrap=character")
|
||||||
|
generate_snapshot("tabs_8", "--tabs=8 --style=full --wrap=never")
|
||||||
|
generate_snapshot("tabs_8_wrapped", "--tabs=8 --style=full --wrap=character")
|
||||||
|
|
||||||
def generate_style_snapshot(style):
|
def generate_style_snapshot(style):
|
||||||
generate_snapshot(style.replace(",","_"), "--style={}".format(style))
|
generate_snapshot(style.replace(",","_"), "--style={}".format(style))
|
||||||
|
40
tests/snapshots/output/tabs_4_wrapped.snapshot.txt
Normal file
40
tests/snapshots/output/tabs_4_wrapped.snapshot.txt
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
───────┬────────────────────────────────────────────────────────────────────────
|
||||||
|
│ File: sample.rs
|
||||||
|
───────┼────────────────────────────────────────────────────────────────────────
|
||||||
|
1 │ struct Rectangle {
|
||||||
|
2 │ width: u32,
|
||||||
|
3 │ height: u32,
|
||||||
|
4 │ }
|
||||||
|
5 │
|
||||||
|
6 _ │ fn main() {
|
||||||
|
7 │ let rect1 = Rectangle { width: 30, height: 50 };
|
||||||
|
8 │
|
||||||
|
9 │ println!(
|
||||||
|
10 ~ │ "The perimeter of the rectangle is {} pixels.",
|
||||||
|
11 ~ │ perimeter(&rect1)
|
||||||
|
12 │ );
|
||||||
|
13 + │ println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
|
||||||
|
14 │ }
|
||||||
|
15 │
|
||||||
|
16 │ fn area(rectangle: &Rectangle) -> u32 {
|
||||||
|
17 │ rectangle.width * rectangle.height
|
||||||
|
18 │ }
|
||||||
|
19 │
|
||||||
|
20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
|
||||||
|
21 + │ (rectangle.width + rectangle.height) * 2
|
||||||
|
22 + │ }
|
||||||
|
23 + │
|
||||||
|
24 │ // Tab alignment:
|
||||||
|
25 │ /*
|
||||||
|
26 │ Indent
|
||||||
|
27 │ 1 2 3 4
|
||||||
|
28 │ 1 ?
|
||||||
|
29 │ 22 ?
|
||||||
|
30 │ 333 ?
|
||||||
|
31 │ 4444 ?
|
||||||
|
32 │ 55555 ?
|
||||||
|
33 │ 666666 ?
|
||||||
|
34 │ 7777777 ?
|
||||||
|
35 │ 88888888 ?
|
||||||
|
36 ~ │ */
|
||||||
|
───────┴────────────────────────────────────────────────────────────────────────
|
40
tests/snapshots/output/tabs_8_wrapped.snapshot.txt
Normal file
40
tests/snapshots/output/tabs_8_wrapped.snapshot.txt
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
───────┬────────────────────────────────────────────────────────────────────────
|
||||||
|
│ File: sample.rs
|
||||||
|
───────┼────────────────────────────────────────────────────────────────────────
|
||||||
|
1 │ struct Rectangle {
|
||||||
|
2 │ width: u32,
|
||||||
|
3 │ height: u32,
|
||||||
|
4 │ }
|
||||||
|
5 │
|
||||||
|
6 _ │ fn main() {
|
||||||
|
7 │ let rect1 = Rectangle { width: 30, height: 50 };
|
||||||
|
8 │
|
||||||
|
9 │ println!(
|
||||||
|
10 ~ │ "The perimeter of the rectangle is {} pixels.",
|
||||||
|
11 ~ │ perimeter(&rect1)
|
||||||
|
12 │ );
|
||||||
|
13 + │ println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
|
||||||
|
14 │ }
|
||||||
|
15 │
|
||||||
|
16 │ fn area(rectangle: &Rectangle) -> u32 {
|
||||||
|
17 │ rectangle.width * rectangle.height
|
||||||
|
18 │ }
|
||||||
|
19 │
|
||||||
|
20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
|
||||||
|
21 + │ (rectangle.width + rectangle.height) * 2
|
||||||
|
22 + │ }
|
||||||
|
23 + │
|
||||||
|
24 │ // Tab alignment:
|
||||||
|
25 │ /*
|
||||||
|
26 │ Indent
|
||||||
|
27 │ 1 2 3 4
|
||||||
|
28 │ 1 ?
|
||||||
|
29 │ 22 ?
|
||||||
|
30 │ 333 ?
|
||||||
|
31 │ 4444 ?
|
||||||
|
32 │ 55555 ?
|
||||||
|
33 │ 666666 ?
|
||||||
|
34 │ 7777777 ?
|
||||||
|
35 │ 88888888 ?
|
||||||
|
36 ~ │ */
|
||||||
|
───────┴────────────────────────────────────────────────────────────────────────
|
40
tests/snapshots/output/tabs_passthrough_wrapped.snapshot.txt
Normal file
40
tests/snapshots/output/tabs_passthrough_wrapped.snapshot.txt
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
───────┬────────────────────────────────────────────────────────────────────────
|
||||||
|
│ File: sample.rs
|
||||||
|
───────┼────────────────────────────────────────────────────────────────────────
|
||||||
|
1 │ struct Rectangle {
|
||||||
|
2 │ width: u32,
|
||||||
|
3 │ height: u32,
|
||||||
|
4 │ }
|
||||||
|
5 │
|
||||||
|
6 _ │ fn main() {
|
||||||
|
7 │ let rect1 = Rectangle { width: 30, height: 50 };
|
||||||
|
8 │
|
||||||
|
9 │ println!(
|
||||||
|
10 ~ │ "The perimeter of the rectangle is {} pixels.",
|
||||||
|
11 ~ │ perimeter(&rect1)
|
||||||
|
12 │ );
|
||||||
|
13 + │ println!(r#"This line contains invalid utf8: "<22><><EFBFBD><EFBFBD><EFBFBD>"#;
|
||||||
|
14 │ }
|
||||||
|
15 │
|
||||||
|
16 │ fn area(rectangle: &Rectangle) -> u32 {
|
||||||
|
17 │ rectangle.width * rectangle.height
|
||||||
|
18 │ }
|
||||||
|
19 │
|
||||||
|
20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
|
||||||
|
21 + │ (rectangle.width + rectangle.height) * 2
|
||||||
|
22 + │ }
|
||||||
|
23 + │
|
||||||
|
24 │ // Tab alignment:
|
||||||
|
25 │ /*
|
||||||
|
26 │ Indent
|
||||||
|
27 │ 1 2 3 4
|
||||||
|
28 │ 1 ?
|
||||||
|
29 │ 22 ?
|
||||||
|
30 │ 333 ?
|
||||||
|
31 │ 4444 ?
|
||||||
|
32 │ 55555 ?
|
||||||
|
33 │ 666666 ?
|
||||||
|
34 │ 7777777 ?
|
||||||
|
35 │ 88888888 ?
|
||||||
|
36 ~ │ */
|
||||||
|
───────┴────────────────────────────────────────────────────────────────────────
|
@ -38,13 +38,14 @@ impl BatTester {
|
|||||||
BatTester { temp_dir, exe }
|
BatTester { temp_dir, exe }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn test_snapshot(&self, name: &str, style: &str, tab_width: u32) {
|
pub fn test_snapshot(&self, name: &str, style: &str, tab_width: u32, wrap: bool) {
|
||||||
let output = Command::new(&self.exe)
|
let output = Command::new(&self.exe)
|
||||||
.current_dir(self.temp_dir.path())
|
.current_dir(self.temp_dir.path())
|
||||||
.args(&[
|
.args(&[
|
||||||
"sample.rs",
|
"sample.rs",
|
||||||
"--decorations=always",
|
"--decorations=always",
|
||||||
"--terminal-width=80",
|
"--terminal-width=80",
|
||||||
|
&format!("--wrap={}", if wrap { "character" } else { "never" }),
|
||||||
&format!("--tabs={}", tab_width),
|
&format!("--tabs={}", tab_width),
|
||||||
&format!("--style={}", style),
|
&format!("--style={}", style),
|
||||||
]).output()
|
]).output()
|
||||||
|
@ -3,36 +3,39 @@ mod tester;
|
|||||||
use tester::BatTester;
|
use tester::BatTester;
|
||||||
|
|
||||||
macro_rules! snapshot_tests {
|
macro_rules! snapshot_tests {
|
||||||
($($test_name: ident: $style: expr => [tabs: $tabs:expr],)*) => {
|
($($test_name: ident: $style: expr => [wrap: $wrap:expr, tabs: $tabs:expr],)*) => {
|
||||||
$(
|
$(
|
||||||
#[test]
|
#[test]
|
||||||
fn $test_name() {
|
fn $test_name() {
|
||||||
let bat_tester = BatTester::new();
|
let bat_tester = BatTester::new();
|
||||||
bat_tester.test_snapshot(stringify!($test_name), $style, $tabs);
|
bat_tester.test_snapshot(stringify!($test_name), $style, $tabs, $wrap);
|
||||||
}
|
}
|
||||||
)*
|
)*
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
snapshot_tests! {
|
snapshot_tests! {
|
||||||
changes: "changes" => [tabs: 8],
|
changes: "changes" => [wrap: false, tabs: 8],
|
||||||
grid: "grid" => [tabs: 8],
|
grid: "grid" => [wrap: false, tabs: 8],
|
||||||
header: "header" => [tabs: 8],
|
header: "header" => [wrap: false, tabs: 8],
|
||||||
numbers: "numbers" => [tabs: 8],
|
numbers: "numbers" => [wrap: false, tabs: 8],
|
||||||
changes_grid: "changes,grid" => [tabs: 8],
|
changes_grid: "changes,grid" => [wrap: false, tabs: 8],
|
||||||
changes_header: "changes,header" => [tabs: 8],
|
changes_header: "changes,header" => [wrap: false, tabs: 8],
|
||||||
changes_numbers: "changes,numbers" => [tabs: 8],
|
changes_numbers: "changes,numbers" => [wrap: false, tabs: 8],
|
||||||
grid_header: "grid,header" => [tabs: 8],
|
grid_header: "grid,header" => [wrap: false, tabs: 8],
|
||||||
grid_numbers: "grid,numbers" => [tabs: 8],
|
grid_numbers: "grid,numbers" => [wrap: false, tabs: 8],
|
||||||
header_numbers: "header,numbers" => [tabs: 8],
|
header_numbers: "header,numbers" => [wrap: false, tabs: 8],
|
||||||
changes_grid_header: "changes,grid,header" => [tabs: 8],
|
changes_grid_header: "changes,grid,header" => [wrap: false, tabs: 8],
|
||||||
changes_grid_numbers: "changes,grid,numbers" => [tabs: 8],
|
changes_grid_numbers: "changes,grid,numbers" => [wrap: false, tabs: 8],
|
||||||
changes_header_numbers: "changes,header,numbers" => [tabs: 8],
|
changes_header_numbers: "changes,header,numbers" => [wrap: false, tabs: 8],
|
||||||
grid_header_numbers: "grid,header,numbers" => [tabs: 8],
|
grid_header_numbers: "grid,header,numbers" => [wrap: false, tabs: 8],
|
||||||
changes_grid_header_numbers: "changes,grid,header,numbers" => [tabs: 8],
|
changes_grid_header_numbers: "changes,grid,header,numbers" => [wrap: false, tabs: 8],
|
||||||
full: "full" => [tabs: 8],
|
full: "full" => [wrap: false, tabs: 8],
|
||||||
plain: "plain" => [tabs: 8],
|
plain: "plain" => [wrap: false, tabs: 8],
|
||||||
tabs_passthrough: "full" => [tabs: 0],
|
tabs_passthrough_wrapped: "full" => [wrap: true, tabs: 0],
|
||||||
tabs_4: "full" => [tabs: 4],
|
tabs_4_wrapped: "full" => [wrap: true, tabs: 4],
|
||||||
tabs_8: "full" => [tabs: 8],
|
tabs_8_wrapped: "full" => [wrap: true, tabs: 8],
|
||||||
|
tabs_passthrough: "full" => [wrap: false, tabs: 0],
|
||||||
|
tabs_4: "full" => [wrap: false, tabs: 4],
|
||||||
|
tabs_8: "full" => [wrap: false, tabs: 8],
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user