on master help sign in
rewrite 6 snapshot tests as integration test
58198d0Lawrence Chou
tests/examples/tabs.txtnew file+10
@@ -0,0 +1,10 @@
1+
2+ 1 2 3 4
3+1 ?
4+22 ?
5+333 ?
6+4444 ?
7+55555 ?
8+666666 ?
9+7777777 ?
10+88888888 ?
tests/integration_tests.rs+114−13
@@ -1,10 +1,7 @@
1extern crate assert_cmd;
1extern crate assert_cmd;
2
2
3−mod tester;
4−
5use assert_cmd::prelude::*;
3use assert_cmd::prelude::*;
6use std::process::Command;
4use std::process::Command;
7−use tester::BatTester;
8
5
9fn bat() -> Command {
6fn bat() -> Command {
10 let mut cmd = Command::main_binary().unwrap();
7 let mut cmd = Command::main_binary().unwrap();
@@ -15,10 +12,6 @@ fn bat() -> Command {
15 cmd
12 cmd
16}
13}
17
14
18−fn tester() -> BatTester {
19− BatTester::new()
20−}
21−
22#[test]
15#[test]
23fn basic() {
16fn basic() {
24 bat()
17 bat()
@@ -105,32 +98,140 @@ fn line_range_last_3() {
105
98
106#[test]
99#[test]
107fn tabs_passthrough_wrapped() {
100fn tabs_passthrough_wrapped() {
108− tester().test_snapshot("tabs_passthrough_wrapped", "full", 0, true);
101+ bat()
102+ .arg("tabs.txt")
103+ .arg("--tabs=0")
104+ .arg("--wrap=character")
105+ .arg("--style=plain")
106+ .arg("--decorations=always")
107+ .assert()
108+ .success()
109+ .stdout("
110+ 1 2 3 4
111+1 ?
112+22 ?
113+333 ?
114+4444 ?
115+55555 ?
116+666666 ?
117+7777777 ?
118+88888888 ?
119+");
109}
120}
110
121
111#[test]
122#[test]
112fn tabs_4_wrapped() {
123fn tabs_4_wrapped() {
113− tester().test_snapshot("tabs_4_wrapped", "full", 4, true);
124+ bat()
125+ .arg("tabs.txt")
126+ .arg("--tabs=4")
127+ .arg("--wrap=character")
128+ .arg("--style=plain")
129+ .arg("--decorations=always")
130+ .assert()
131+ .success()
132+ .stdout("
133+ 1 2 3 4
134+1 ?
135+22 ?
136+333 ?
137+4444 ?
138+55555 ?
139+666666 ?
140+7777777 ?
141+88888888 ?
142+");
114}
143}
115
144
116#[test]
145#[test]
117fn tabs_8_wrapped() {
146fn tabs_8_wrapped() {
118− tester().test_snapshot("tabs_8_wrapped", "full", 8, true);
147+ bat()
148+ .arg("tabs.txt")
149+ .arg("--tabs=8")
150+ .arg("--wrap=character")
151+ .arg("--style=plain")
152+ .arg("--decorations=always")
153+ .assert()
154+ .success()
155+ .stdout("
156+ 1 2 3 4
157+1 ?
158+22 ?
159+333 ?
160+4444 ?
161+55555 ?
162+666666 ?
163+7777777 ?
164+88888888 ?
165+");
119}
166}
120
167
121#[test]
168#[test]
122fn tabs_passthrough() {
169fn tabs_passthrough() {
123− tester().test_snapshot("tabs_passthrough", "full", 0, false);
170+ bat()
171+ .arg("tabs.txt")
172+ .arg("--tabs=0")
173+ .arg("--wrap=never")
174+ .arg("--style=plain")
175+ .arg("--decorations=always")
176+ .assert()
177+ .success()
178+ .stdout("
179+ 1 2 3 4
180+1 ?
181+22 ?
182+333 ?
183+4444 ?
184+55555 ?
185+666666 ?
186+7777777 ?
187+88888888 ?
188+");
124}
189}
125
190
126#[test]
191#[test]
127fn tabs_4() {
192fn tabs_4() {
128− tester().test_snapshot("tabs_4", "full", 4, false);
193+ bat()
194+ .arg("tabs.txt")
195+ .arg("--tabs=4")
196+ .arg("--wrap=never")
197+ .arg("--style=plain")
198+ .arg("--decorations=always")
199+ .assert()
200+ .success()
201+ .stdout("
202+ 1 2 3 4
203+1 ?
204+22 ?
205+333 ?
206+4444 ?
207+55555 ?
208+666666 ?
209+7777777 ?
210+88888888 ?
211+");
129}
212}
130
213
131#[test]
214#[test]
132fn tabs_8() {
215fn tabs_8() {
133− tester().test_snapshot("tabs_8", "full", 8, false);
216+ bat()
217+ .arg("tabs.txt")
218+ .arg("--tabs=8")
219+ .arg("--wrap=never")
220+ .arg("--style=plain")
221+ .arg("--decorations=always")
222+ .assert()
223+ .success()
224+ .stdout("
225+ 1 2 3 4
226+1 ?
227+22 ?
228+333 ?
229+4444 ?
230+55555 ?
231+666666 ?
232+7777777 ?
233+88888888 ?
234+");
134}
235}
135
236
136#[test]
237#[test]
tests/snapshots/output/tabs_4.snapshot.txtdeleted−40
@@ -1,40 +0,0 @@
1−───────┬────────────────────────────────────────────────────────────────────────
2− │ File: sample.rs
3−───────┼────────────────────────────────────────────────────────────────────────
4− 1 │ struct Rectangle {
5− 2 │ width: u32,
6− 3 │ height: u32,
7− 4 │ }
8− 5 │
9− 6 _ │ fn main() {
10− 7 │ let rect1 = Rectangle { width: 30, height: 50 };
11− 8 │
12− 9 │ println!(
13− 10 ~ │ "The perimeter of the rectangle is {} pixels.",
14− 11 ~ │ perimeter(&rect1)
15− 12 │ );
16− 13 + │ println!(r#"This line contains invalid utf8: "�����"#;
17− 14 │ }
18− 15 │
19− 16 │ fn area(rectangle: &Rectangle) -> u32 {
20− 17 │ rectangle.width * rectangle.height
21− 18 │ }
22− 19 │
23− 20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
24− 21 + │ (rectangle.width + rectangle.height) * 2
25− 22 + │ }
26− 23 + │
27− 24 │ // Tab alignment:
28− 25 │ /*
29− 26 │ Indent
30− 27 │ 1 2 3 4
31− 28 │ 1 ?
32− 29 │ 22 ?
33− 30 │ 333 ?
34− 31 │ 4444 ?
35− 32 │ 55555 ?
36− 33 │ 666666 ?
37− 34 │ 7777777 ?
38− 35 │ 88888888 ?
39− 36 ~ │ */
40−───────┴────────────────────────────────────────────────────────────────────────
tests/snapshots/output/tabs_4_wrapped.snapshot.txtdeleted−40
@@ -1,40 +0,0 @@
1−───────┬────────────────────────────────────────────────────────────────────────
2− │ File: sample.rs
3−───────┼────────────────────────────────────────────────────────────────────────
4− 1 │ struct Rectangle {
5− 2 │ width: u32,
6− 3 │ height: u32,
7− 4 │ }
8− 5 │
9− 6 _ │ fn main() {
10− 7 │ let rect1 = Rectangle { width: 30, height: 50 };
11− 8 │
12− 9 │ println!(
13− 10 ~ │ "The perimeter of the rectangle is {} pixels.",
14− 11 ~ │ perimeter(&rect1)
15− 12 │ );
16− 13 + │ println!(r#"This line contains invalid utf8: "�����"#;
17− 14 │ }
18− 15 │
19− 16 │ fn area(rectangle: &Rectangle) -> u32 {
20− 17 │ rectangle.width * rectangle.height
21− 18 │ }
22− 19 │
23− 20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
24− 21 + │ (rectangle.width + rectangle.height) * 2
25− 22 + │ }
26− 23 + │
27− 24 │ // Tab alignment:
28− 25 │ /*
29− 26 │ Indent
30− 27 │ 1 2 3 4
31− 28 │ 1 ?
32− 29 │ 22 ?
33− 30 │ 333 ?
34− 31 │ 4444 ?
35− 32 │ 55555 ?
36− 33 │ 666666 ?
37− 34 │ 7777777 ?
38− 35 │ 88888888 ?
39− 36 ~ │ */
40−───────┴────────────────────────────────────────────────────────────────────────
tests/snapshots/output/tabs_8.snapshot.txtdeleted−40
@@ -1,40 +0,0 @@
1−───────┬────────────────────────────────────────────────────────────────────────
2− │ File: sample.rs
3−───────┼────────────────────────────────────────────────────────────────────────
4− 1 │ struct Rectangle {
5− 2 │ width: u32,
6− 3 │ height: u32,
7− 4 │ }
8− 5 │
9− 6 _ │ fn main() {
10− 7 │ let rect1 = Rectangle { width: 30, height: 50 };
11− 8 │
12− 9 │ println!(
13− 10 ~ │ "The perimeter of the rectangle is {} pixels.",
14− 11 ~ │ perimeter(&rect1)
15− 12 │ );
16− 13 + │ println!(r#"This line contains invalid utf8: "�����"#;
17− 14 │ }
18− 15 │
19− 16 │ fn area(rectangle: &Rectangle) -> u32 {
20− 17 │ rectangle.width * rectangle.height
21− 18 │ }
22− 19 │
23− 20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
24− 21 + │ (rectangle.width + rectangle.height) * 2
25− 22 + │ }
26− 23 + │
27− 24 │ // Tab alignment:
28− 25 │ /*
29− 26 │ Indent
30− 27 │ 1 2 3 4
31− 28 │ 1 ?
32− 29 │ 22 ?
33− 30 │ 333 ?
34− 31 │ 4444 ?
35− 32 │ 55555 ?
36− 33 │ 666666 ?
37− 34 │ 7777777 ?
38− 35 │ 88888888 ?
39− 36 ~ │ */
40−───────┴────────────────────────────────────────────────────────────────────────
tests/snapshots/output/tabs_8_wrapped.snapshot.txtdeleted−40
@@ -1,40 +0,0 @@
1−───────┬────────────────────────────────────────────────────────────────────────
2− │ File: sample.rs
3−───────┼────────────────────────────────────────────────────────────────────────
4− 1 │ struct Rectangle {
5− 2 │ width: u32,
6− 3 │ height: u32,
7− 4 │ }
8− 5 │
9− 6 _ │ fn main() {
10− 7 │ let rect1 = Rectangle { width: 30, height: 50 };
11− 8 │
12− 9 │ println!(
13− 10 ~ │ "The perimeter of the rectangle is {} pixels.",
14− 11 ~ │ perimeter(&rect1)
15− 12 │ );
16− 13 + │ println!(r#"This line contains invalid utf8: "�����"#;
17− 14 │ }
18− 15 │
19− 16 │ fn area(rectangle: &Rectangle) -> u32 {
20− 17 │ rectangle.width * rectangle.height
21− 18 │ }
22− 19 │
23− 20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
24− 21 + │ (rectangle.width + rectangle.height) * 2
25− 22 + │ }
26− 23 + │
27− 24 │ // Tab alignment:
28− 25 │ /*
29− 26 │ Indent
30− 27 │ 1 2 3 4
31− 28 │ 1 ?
32− 29 │ 22 ?
33− 30 │ 333 ?
34− 31 │ 4444 ?
35− 32 │ 55555 ?
36− 33 │ 666666 ?
37− 34 │ 7777777 ?
38− 35 │ 88888888 ?
39− 36 ~ │ */
40−───────┴────────────────────────────────────────────────────────────────────────
tests/snapshots/output/tabs_passthrough.snapshot.txtdeleted−40
@@ -1,40 +0,0 @@
1−───────┬────────────────────────────────────────────────────────────────────────
2− │ File: sample.rs
3−───────┼────────────────────────────────────────────────────────────────────────
4− 1 │ struct Rectangle {
5− 2 │ width: u32,
6− 3 │ height: u32,
7− 4 │ }
8− 5 │
9− 6 _ │ fn main() {
10− 7 │ let rect1 = Rectangle { width: 30, height: 50 };
11− 8 │
12− 9 │ println!(
13− 10 ~ │ "The perimeter of the rectangle is {} pixels.",
14− 11 ~ │ perimeter(&rect1)
15− 12 │ );
16− 13 + │ println!(r#"This line contains invalid utf8: "�����"#;
17− 14 │ }
18− 15 │
19− 16 │ fn area(rectangle: &Rectangle) -> u32 {
20− 17 │ rectangle.width * rectangle.height
21− 18 │ }
22− 19 │
23− 20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
24− 21 + │ (rectangle.width + rectangle.height) * 2
25− 22 + │ }
26− 23 + │
27− 24 │ // Tab alignment:
28− 25 │ /*
29− 26 │ Indent
30− 27 │ 1 2 3 4
31− 28 │ 1 ?
32− 29 │ 22 ?
33− 30 │ 333 ?
34− 31 │ 4444 ?
35− 32 │ 55555 ?
36− 33 │ 666666 ?
37− 34 │ 7777777 ?
38− 35 │ 88888888 ?
39− 36 ~ │ */
40−───────┴────────────────────────────────────────────────────────────────────────
tests/snapshots/output/tabs_passthrough_wrapped.snapshot.txtdeleted−40
@@ -1,40 +0,0 @@
1−───────┬────────────────────────────────────────────────────────────────────────
2− │ File: sample.rs
3−───────┼────────────────────────────────────────────────────────────────────────
4− 1 │ struct Rectangle {
5− 2 │ width: u32,
6− 3 │ height: u32,
7− 4 │ }
8− 5 │
9− 6 _ │ fn main() {
10− 7 │ let rect1 = Rectangle { width: 30, height: 50 };
11− 8 │
12− 9 │ println!(
13− 10 ~ │ "The perimeter of the rectangle is {} pixels.",
14− 11 ~ │ perimeter(&rect1)
15− 12 │ );
16− 13 + │ println!(r#"This line contains invalid utf8: "�����"#;
17− 14 │ }
18− 15 │
19− 16 │ fn area(rectangle: &Rectangle) -> u32 {
20− 17 │ rectangle.width * rectangle.height
21− 18 │ }
22− 19 │
23− 20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
24− 21 + │ (rectangle.width + rectangle.height) * 2
25− 22 + │ }
26− 23 + │
27− 24 │ // Tab alignment:
28− 25 │ /*
29− 26 │ Indent
30− 27 │ 1 2 3 4
31− 28 │ 1 ?
32− 29 │ 22 ?
33− 30 │ 333 ?
34− 31 │ 4444 ?
35− 32 │ 55555 ?
36− 33 │ 666666 ?
37− 34 │ 7777777 ?
38− 35 │ 88888888 ?
39− 36 ~ │ */
40−───────┴────────────────────────────────────────────────────────────────────────