Skip to content

Commit 719a9e7

Browse files
committed
fix: Add test for mix of should_panic and ignore
1 parent d2e441a commit 719a9e7

File tree

1 file changed

+77
-8
lines changed

1 file changed

+77
-8
lines changed

crates/libtest2/tests/testsuite/should_panic.rs

Lines changed: 77 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ fn intentionally_panics_with_message(_context: &libtest2::TestContext) {
3232
fn panics_with_the_wrong_message(_context: &libtest2::TestContext) {
3333
panic!("with the wrong message")
3434
}
35+
36+
#[libtest2::test]
37+
#[ignore]
38+
#[should_panic]
39+
#[ignore = "this attribute should just be skipped"]
40+
fn intentionally_panics_but_is_usually_ignored(_context: &libtest2::TestContext) {
41+
panic!("whatever")
42+
}
3543
"#,
3644
false,
3745
);
@@ -62,11 +70,72 @@ fn normal() {
6270
101,
6371
str![[r#"
6472
65-
running 4 tests
66-
test accidentally_panics ... FAILED
67-
test intentionally_panics ... ok
68-
test intentionally_panics_with_message ... ok
69-
test panics_with_the_wrong_message ... FAILED
73+
running 5 tests
74+
test accidentally_panics ... FAILED
75+
test intentionally_panics ... ok
76+
test intentionally_panics_but_is_usually_ignored ... ignored
77+
test intentionally_panics_with_message ... ok
78+
test panics_with_the_wrong_message ... FAILED
79+
80+
failures:
81+
82+
---- accidentally_panics ----
83+
test panicked: uh oh
84+
85+
---- panics_with_the_wrong_message ----
86+
panic did not contain expected string
87+
panic message: "with the wrong message"
88+
expected substring: "in a controlled manner"
89+
90+
91+
failures:
92+
accidentally_panics
93+
panics_with_the_wrong_message
94+
95+
test result: FAILED. 2 passed; 2 failed; 1 ignored; 0 filtered out; finished in [..]s
96+
97+
98+
"#]],
99+
str![[r#"
100+
101+
running 5 tests
102+
...
103+
104+
failures:
105+
106+
---- accidentally_panics ----
107+
test panicked: uh oh
108+
109+
---- panics_with_the_wrong_message ----
110+
panic did not contain expected string
111+
panic message: "with the wrong message"
112+
expected substring: "in a controlled manner"
113+
114+
115+
failures:
116+
accidentally_panics
117+
panics_with_the_wrong_message
118+
119+
test result: FAILED. 2 passed; 2 failed; 1 ignored; 0 filtered out; finished in [..]s
120+
121+
122+
"#]],
123+
);
124+
}
125+
126+
#[test]
127+
fn include_ignored_normal() {
128+
check(
129+
&["--include-ignored"],
130+
101,
131+
str![[r#"
132+
133+
running 5 tests
134+
test accidentally_panics ... FAILED
135+
test intentionally_panics ... ok
136+
test intentionally_panics_but_is_usually_ignored ... ok
137+
test intentionally_panics_with_message ... ok
138+
test panics_with_the_wrong_message ... FAILED
70139
71140
failures:
72141
@@ -83,13 +152,13 @@ failures:
83152
accidentally_panics
84153
panics_with_the_wrong_message
85154
86-
test result: FAILED. 2 passed; 2 failed; 0 ignored; 0 filtered out; finished in [..]s
155+
test result: FAILED. 3 passed; 2 failed; 0 ignored; 0 filtered out; finished in [..]s
87156
88157
89158
"#]],
90159
str![[r#"
91160
92-
running 4 tests
161+
running 5 tests
93162
...
94163
95164
failures:
@@ -107,7 +176,7 @@ failures:
107176
accidentally_panics
108177
panics_with_the_wrong_message
109178
110-
test result: FAILED. 2 passed; 2 failed; 0 ignored; 0 filtered out; finished in [..]s
179+
test result: FAILED. 3 passed; 2 failed; 0 ignored; 0 filtered out; finished in [..]s
111180
112181
113182
"#]],

0 commit comments

Comments
 (0)