File tree 3 files changed +17
-4
lines changed
3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -153,12 +153,13 @@ pub fn test_main_static_abort(tests: &[&TestDescAndFn]) {
153
153
// If we're being run in SpawnedSecondary mode, run the test here. run_test
154
154
// will then exit the process.
155
155
if let Ok ( name) = env:: var ( SECONDARY_TEST_INVOKER_VAR ) {
156
+ env:: remove_var ( SECONDARY_TEST_INVOKER_VAR ) ;
156
157
let test = tests
157
158
. iter ( )
158
159
. filter ( |test| test. desc . name . as_slice ( ) == name)
159
160
. map ( make_owned_test)
160
161
. next ( )
161
- . expect ( "couldn't find a test with the provided name" ) ;
162
+ . expect ( & format ! ( "couldn't find a test with the provided name '{}'" , name ) ) ;
162
163
let TestDescAndFn { desc, testfn } = test;
163
164
let testfn = match testfn {
164
165
StaticTestFn ( f) => f,
Original file line number Diff line number Diff line change 11
11
#![ cfg( test) ]
12
12
13
13
use std:: io:: Write ;
14
+ use std:: env;
14
15
15
16
#[ test]
16
17
fn it_works ( ) {
@@ -35,3 +36,13 @@ fn it_fails() {
35
36
fn it_exits ( ) {
36
37
std:: process:: exit ( 123 ) ;
37
38
}
39
+
40
+ #[ test]
41
+ fn no_residual_environment ( ) {
42
+ for ( key, _) in env:: vars ( ) {
43
+ // Look for keys like __RUST_TEST_INVOKE.
44
+ if key. contains ( "TEST_INVOKE" ) {
45
+ panic ! ( "shouldn't have '{}' in environment" , key) ;
46
+ }
47
+ }
48
+ }
Original file line number Diff line number Diff line change 1
1
2
- running 4 tests
2
+ running 5 tests
3
3
test it_exits ... FAILED
4
4
test it_fails ... FAILED
5
5
test it_panics ... ok
6
6
test it_works ... ok
7
+ test no_residual_environment ... ok
7
8
8
9
failures:
9
10
@@ -17,13 +18,13 @@ testing123
17
18
testing321
18
19
thread 'main' panicked at 'assertion failed: `(left == right)`
19
20
left: `2`,
20
- right: `5`', $DIR/test-panic-abort.rs:31 :5
21
+ right: `5`', $DIR/test-panic-abort.rs:32 :5
21
22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
22
23
23
24
24
25
failures:
25
26
it_exits
26
27
it_fails
27
28
28
- test result: FAILED. 2 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out
29
+ test result: FAILED. 3 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out
29
30
You can’t perform that action at this time.
0 commit comments