File tree 3 files changed +36
-24
lines changed
src/tools/run-make-support/src
3 files changed +36
-24
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,18 @@ impl RustcInvocationBuilder {
76
76
}
77
77
output
78
78
}
79
+
80
+ #[ track_caller]
81
+ pub fn run_fail_assert_exit_code ( & mut self , code : i32 ) -> Output {
82
+ let caller_location = std:: panic:: Location :: caller ( ) ;
83
+ let caller_line_number = caller_location. line ( ) ;
84
+
85
+ let output = self . cmd . output ( ) . unwrap ( ) ;
86
+ if output. status . code ( ) . unwrap ( ) != code {
87
+ handle_failed_output ( & format ! ( "{:#?}" , self . cmd) , output, caller_line_number) ;
88
+ }
89
+ output
90
+ }
79
91
}
80
92
81
93
#[ derive( Debug ) ]
Original file line number Diff line number Diff line change @@ -57,6 +57,18 @@ impl RustdocInvocationBuilder {
57
57
}
58
58
output
59
59
}
60
+
61
+ #[ track_caller]
62
+ pub fn run_fail_assert_exit_code ( & mut self , code : i32 ) -> Output {
63
+ let caller_location = std:: panic:: Location :: caller ( ) ;
64
+ let caller_line_number = caller_location. line ( ) ;
65
+
66
+ let output = self . cmd . output ( ) . unwrap ( ) ;
67
+ if output. status . code ( ) . unwrap ( ) != code {
68
+ handle_failed_output ( & format ! ( "{:#?}" , self . cmd) , output, caller_line_number) ;
69
+ }
70
+ output
71
+ }
60
72
}
61
73
62
74
fn setup_common_rustdoc_build_cmd ( ) -> Command {
Original file line number Diff line number Diff line change @@ -7,47 +7,35 @@ fn main() {
7
7
. arg ( "success.rs" )
8
8
. run ( ) ;
9
9
10
- assert_eq ! ( rustc( )
10
+ rustc ( )
11
11
. arg ( "--invalid-arg-foo" )
12
- . run_fail( )
13
- . status
14
- . code( ) . unwrap( ) , 1 ) ;
12
+ . run_fail_assert_exit_code ( 1 ) ;
15
13
16
- assert_eq ! ( rustc( )
14
+ rustc ( )
17
15
. arg ( "compile-error.rs" )
18
- . run_fail( )
19
- . status
20
- . code( ) . unwrap( ) , 1 ) ;
16
+ . run_fail_assert_exit_code ( 1 ) ;
21
17
22
- assert_eq ! ( rustc( )
18
+ rustc ( )
23
19
. env ( "RUSTC_ICE" , "0" )
24
20
. arg ( "-Ztreat-err-as-bug" )
25
21
. arg ( "compile-error.rs" )
26
- . run_fail( )
27
- . status
28
- . code( ) . unwrap( ) , 101 ) ;
22
+ . run_fail_assert_exit_code ( 101 ) ;
29
23
30
24
rustdoc ( )
31
25
. arg ( "-o" )
32
26
. arg_file ( & tempdir ( ) . join ( "exit-code" ) )
33
27
. arg ( "success.rs" )
34
28
. run ( ) ;
35
29
36
- assert_eq ! ( rustdoc( )
30
+ rustdoc ( )
37
31
. arg ( "--invalid-arg-foo" )
38
- . run_fail( )
39
- . status
40
- . code( ) . unwrap( ) , 1 ) ;
32
+ . run_fail_assert_exit_code ( 1 ) ;
41
33
42
- assert_eq ! ( rustdoc( )
34
+ rustdoc ( )
43
35
. arg ( "compile-error.rs" )
44
- . run_fail( )
45
- . status
46
- . code( ) . unwrap( ) , 1 ) ;
36
+ . run_fail_assert_exit_code ( 1 ) ;
47
37
48
- assert_eq ! ( rustdoc( )
38
+ rustdoc ( )
49
39
. arg ( "lint-failure.rs" )
50
- . run_fail( )
51
- . status
52
- . code( ) . unwrap( ) , 1 ) ;
40
+ . run_fail_assert_exit_code ( 1 ) ;
53
41
}
You can’t perform that action at this time.
0 commit comments