@@ -23,6 +23,8 @@ use util::logv;
23
23
use std:: rt:: io;
24
24
use std:: rt:: io:: fs;
25
25
use std:: rt:: io:: File ;
26
+ use std:: rt:: io:: process;
27
+ use std:: rt:: io:: process:: ProcessExit ;
26
28
use std:: os;
27
29
use std:: str;
28
30
use std:: vec;
@@ -60,7 +62,7 @@ pub fn run_metrics(config: config, testfile: ~str, mm: &mut MetricMap) {
60
62
fn run_cfail_test ( config : & config , props : & TestProps , testfile : & Path ) {
61
63
let ProcRes = compile_test ( config, props, testfile) ;
62
64
63
- if ProcRes . status == 0 {
65
+ if ProcRes . status . success ( ) {
64
66
fatal_ProcRes ( ~"compile-fail test compiled successfully!", &ProcRes);
65
67
}
66
68
@@ -81,7 +83,7 @@ fn run_rfail_test(config: &config, props: &TestProps, testfile: &Path) {
81
83
let ProcRes = if !config. jit {
82
84
let ProcRes = compile_test ( config, props, testfile) ;
83
85
84
- if ProcRes . status != 0 {
86
+ if ! ProcRes . status . success ( ) {
85
87
fatal_ProcRes ( ~"compilation failed!", &ProcRes);
86
88
}
87
89
@@ -92,7 +94,7 @@ fn run_rfail_test(config: &config, props: &TestProps, testfile: &Path) {
92
94
93
95
// The value our Makefile configures valgrind to return on failure
94
96
static VALGRIND_ERR: int = 100;
95
- if ProcRes.status == VALGRIND_ERR {
97
+ if ProcRes.status.matches_exit_status( VALGRIND_ERR) {
96
98
fatal_ProcRes(~" run-fail test isn' t valgrind-clean!", &ProcRes);
97
99
}
98
100
@@ -115,10 +117,9 @@ fn run_rfail_test(config: &config, props: &TestProps, testfile: &Path) {
115
117
fn check_correct_failure_status ( ProcRes : & ProcRes ) {
116
118
// The value the rust runtime returns on failure
117
119
static RUST_ERR : int = 101 ;
118
- if ProcRes . status != RUST_ERR {
120
+ if ! ProcRes . status . matches_exit_status ( RUST_ERR ) {
119
121
fatal_ProcRes (
120
- format ! ( "failure produced the wrong error code: {}" ,
121
- ProcRes . status) ,
122
+ format ! ( "failure produced the wrong error: {}" , ProcRes . status) ,
122
123
ProcRes ) ;
123
124
}
124
125
}
@@ -127,19 +128,19 @@ fn run_rpass_test(config: &config, props: &TestProps, testfile: &Path) {
127
128
if !config. jit {
128
129
let mut ProcRes = compile_test ( config, props, testfile) ;
129
130
130
- if ProcRes . status != 0 {
131
+ if ! ProcRes . status . success ( ) {
131
132
fatal_ProcRes ( ~"compilation failed!", &ProcRes);
132
133
}
133
134
134
135
ProcRes = exec_compiled_test(config, props, testfile);
135
136
136
- if ProcRes.status != 0 {
137
+ if ! ProcRes.status.success() {
137
138
fatal_ProcRes(~" test run failed!", &ProcRes);
138
139
}
139
140
} else {
140
141
let ProcRes = jit_test(config, props, testfile);
141
142
142
- if ProcRes.status != 0 { fatal_ProcRes(~" jit failed!", &ProcRes); }
143
+ if ! ProcRes.status.success() { fatal_ProcRes(~" jit failed!", &ProcRes); }
143
144
}
144
145
}
145
146
@@ -160,7 +161,7 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
160
161
logv ( config, format ! ( "pretty-printing round {}" , round) ) ;
161
162
let ProcRes = print_source ( config, testfile, srcs[ round] . clone ( ) ) ;
162
163
163
- if ProcRes . status != 0 {
164
+ if ! ProcRes . status . success ( ) {
164
165
fatal_ProcRes ( format ! ( "pretty-printing failed in round {}" , round) ,
165
166
& ProcRes ) ;
166
167
}
@@ -192,7 +193,7 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
192
193
// Finally, let's make sure it actually appears to remain valid code
193
194
let ProcRes = typecheck_source ( config, props, testfile, actual) ;
194
195
195
- if ProcRes . status != 0 {
196
+ if ! ProcRes . status . success ( ) {
196
197
fatal_ProcRes ( ~"pretty-printed source does not typecheck", & ProcRes ) ;
197
198
}
198
199
@@ -264,7 +265,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
264
265
265
266
// compile test file (it shoud have 'compile-flags:-g' in the header)
266
267
let mut ProcRes = compile_test( config, props, testfile) ;
267
- if ProcRes . status != 0 {
268
+ if ! ProcRes . status. success ( ) {
268
269
fatal_ProcRes( ~"compilation failed!", & ProcRes) ;
269
270
}
270
271
@@ -375,7 +376,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
375
376
}
376
377
}
377
378
378
- if ProcRes.status != 0 {
379
+ if ! ProcRes.status.success() {
379
380
fatal(~" gdb failed to execute");
380
381
}
381
382
let num_check_lines = check_lines.len();
@@ -431,7 +432,7 @@ fn check_error_patterns(props: &TestProps,
431
432
}
432
433
}
433
434
434
- if ProcRes.status == 0 {
435
+ if ProcRes.status.success() {
435
436
fatal(~" process did not return an error status");
436
437
}
437
438
@@ -473,7 +474,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
473
474
let mut found_flags = vec::from_elem(
474
475
expected_errors.len(), false);
475
476
476
- if ProcRes.status == 0 {
477
+ if ProcRes.status.success() {
477
478
fatal(~" process did not return an error status");
478
479
}
479
480
@@ -625,7 +626,7 @@ fn scan_string(haystack: &str, needle: &str, idx: &mut uint) -> bool {
625
626
626
627
struct ProcArgs {prog: ~str, args: ~[~str]}
627
628
628
- struct ProcRes {status: int , stdout: ~str, stderr: ~str, cmdline: ~str}
629
+ struct ProcRes {status: ProcessExit , stdout: ~str, stderr: ~str, cmdline: ~str}
629
630
630
631
fn compile_test(config: &config, props: &TestProps,
631
632
testfile: &Path) -> ProcRes {
@@ -692,7 +693,7 @@ fn compose_and_run_compiler(
692
693
|a,b| make_lib_name(a, b, testfile), &abs_ab);
693
694
let auxres = compose_and_run(config, &abs_ab, aux_args, ~[],
694
695
config.compile_lib_path, None);
695
- if auxres.status != 0 {
696
+ if ! auxres.status.success() {
696
697
fatal_ProcRes(
697
698
format!(" auxiliary build of { } failed to compile: ",
698
699
abs_ab.display()),
@@ -966,7 +967,12 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
966
967
967
968
dump_output(config, testfile, stdout_out, stderr_out);
968
969
969
- ProcRes {status: exitcode, stdout: stdout_out, stderr: stderr_out, cmdline: cmdline }
970
+ ProcRes {
971
+ status: process::ExitStatus(exitcode),
972
+ stdout: stdout_out,
973
+ stderr: stderr_out,
974
+ cmdline: cmdline
975
+ }
970
976
}
971
977
972
978
fn _dummy_exec_compiled_test(config: &config, props: &TestProps,
@@ -976,9 +982,9 @@ fn _dummy_exec_compiled_test(config: &config, props: &TestProps,
976
982
let cmdline = make_cmdline(" ", args.prog, args.args);
977
983
978
984
match config.mode {
979
- mode_run_fail => ProcRes {status: 101, stdout: ~" ",
985
+ mode_run_fail => ProcRes {status: process::ExitStatus( 101) , stdout: ~" ",
980
986
stderr: ~" ", cmdline: cmdline},
981
- _ => ProcRes {status: 0 , stdout: ~" ",
987
+ _ => ProcRes {status: process::ExitStatus(0) , stdout: ~" ",
982
988
stderr: ~" ", cmdline: cmdline}
983
989
}
984
990
}
@@ -1099,33 +1105,33 @@ fn run_codegen_test(config: &config, props: &TestProps,
1099
1105
}
1100
1106
1101
1107
let mut ProcRes = compile_test_and_save_bitcode(config, props, testfile);
1102
- if ProcRes.status != 0 {
1108
+ if ! ProcRes.status.success() {
1103
1109
fatal_ProcRes(~" compilation failed!", &ProcRes);
1104
1110
}
1105
1111
1106
1112
ProcRes = extract_function_from_bitcode(config, props, " test", testfile, " ");
1107
- if ProcRes.status != 0 {
1113
+ if ! ProcRes.status.success() {
1108
1114
fatal_ProcRes(~" extracting ' test' function failed", &ProcRes);
1109
1115
}
1110
1116
1111
1117
ProcRes = disassemble_extract(config, props, testfile, " ");
1112
- if ProcRes.status != 0 {
1118
+ if ! ProcRes.status.success() {
1113
1119
fatal_ProcRes(~" disassembling extract failed", &ProcRes);
1114
1120
}
1115
1121
1116
1122
1117
1123
let mut ProcRes = compile_cc_with_clang_and_save_bitcode(config, props, testfile);
1118
- if ProcRes.status != 0 {
1124
+ if ! ProcRes.status.success() {
1119
1125
fatal_ProcRes(~" compilation failed!", &ProcRes);
1120
1126
}
1121
1127
1122
1128
ProcRes = extract_function_from_bitcode(config, props, " test", testfile, " clang");
1123
- if ProcRes.status != 0 {
1129
+ if ! ProcRes.status.success() {
1124
1130
fatal_ProcRes(~" extracting ' test' function failed", &ProcRes);
1125
1131
}
1126
1132
1127
1133
ProcRes = disassemble_extract(config, props, testfile, " clang");
1128
- if ProcRes.status != 0 {
1134
+ if ! ProcRes.status.success() {
1129
1135
fatal_ProcRes(~" disassembling extract failed", &ProcRes);
1130
1136
}
1131
1137
0 commit comments