@@ -23,6 +23,8 @@ use util::logv;
2323use std:: rt:: io;
2424use std:: rt:: io:: fs;
2525use std:: rt:: io:: File ;
26+ use std:: rt:: io:: process;
27+ use std:: rt:: io:: process:: ProcessExit ;
2628use std:: os;
2729use std:: str;
2830use std:: vec;
@@ -60,7 +62,7 @@ pub fn run_metrics(config: config, testfile: ~str, mm: &mut MetricMap) {
6062fn run_cfail_test ( config : & config , props : & TestProps , testfile : & Path ) {
6163 let ProcRes = compile_test ( config, props, testfile) ;
6264
63- if ProcRes . status == 0 {
65+ if ProcRes . status . success ( ) {
6466 fatal_ProcRes ( ~"compile-fail test compiled successfully!", &ProcRes);
6567 }
6668
@@ -81,7 +83,7 @@ fn run_rfail_test(config: &config, props: &TestProps, testfile: &Path) {
8183 let ProcRes = if !config. jit {
8284 let ProcRes = compile_test ( config, props, testfile) ;
8385
84- if ProcRes . status != 0 {
86+ if ! ProcRes . status . success ( ) {
8587 fatal_ProcRes ( ~"compilation failed!", &ProcRes);
8688 }
8789
@@ -92,7 +94,7 @@ fn run_rfail_test(config: &config, props: &TestProps, testfile: &Path) {
9294
9395 // The value our Makefile configures valgrind to return on failure
9496 static VALGRIND_ERR: int = 100;
95- if ProcRes.status == VALGRIND_ERR {
97+ if ProcRes.status.matches_exit_status( VALGRIND_ERR) {
9698 fatal_ProcRes(~" run-fail test isn' t valgrind-clean!", &ProcRes);
9799 }
98100
@@ -115,10 +117,9 @@ fn run_rfail_test(config: &config, props: &TestProps, testfile: &Path) {
115117fn check_correct_failure_status ( ProcRes : & ProcRes ) {
116118 // The value the rust runtime returns on failure
117119 static RUST_ERR : int = 101 ;
118- if ProcRes . status != RUST_ERR {
120+ if ! ProcRes . status . matches_exit_status ( RUST_ERR ) {
119121 fatal_ProcRes (
120- format ! ( "failure produced the wrong error code: {}" ,
121- ProcRes . status) ,
122+ format ! ( "failure produced the wrong error: {}" , ProcRes . status) ,
122123 ProcRes ) ;
123124 }
124125}
@@ -127,19 +128,19 @@ fn run_rpass_test(config: &config, props: &TestProps, testfile: &Path) {
127128 if !config. jit {
128129 let mut ProcRes = compile_test ( config, props, testfile) ;
129130
130- if ProcRes . status != 0 {
131+ if ! ProcRes . status . success ( ) {
131132 fatal_ProcRes ( ~"compilation failed!", &ProcRes);
132133 }
133134
134135 ProcRes = exec_compiled_test(config, props, testfile);
135136
136- if ProcRes.status != 0 {
137+ if ! ProcRes.status.success() {
137138 fatal_ProcRes(~" test run failed!", &ProcRes);
138139 }
139140 } else {
140141 let ProcRes = jit_test(config, props, testfile);
141142
142- if ProcRes.status != 0 { fatal_ProcRes(~" jit failed!", &ProcRes); }
143+ if ! ProcRes.status.success() { fatal_ProcRes(~" jit failed!", &ProcRes); }
143144 }
144145}
145146
@@ -160,7 +161,7 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
160161 logv ( config, format ! ( "pretty-printing round {}" , round) ) ;
161162 let ProcRes = print_source ( config, testfile, srcs[ round] . clone ( ) ) ;
162163
163- if ProcRes . status != 0 {
164+ if ! ProcRes . status . success ( ) {
164165 fatal_ProcRes ( format ! ( "pretty-printing failed in round {}" , round) ,
165166 & ProcRes ) ;
166167 }
@@ -192,7 +193,7 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
192193 // Finally, let's make sure it actually appears to remain valid code
193194 let ProcRes = typecheck_source ( config, props, testfile, actual) ;
194195
195- if ProcRes . status != 0 {
196+ if ! ProcRes . status . success ( ) {
196197 fatal_ProcRes ( ~"pretty-printed source does not typecheck", & ProcRes ) ;
197198 }
198199
@@ -264,7 +265,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
264265
265266 // compile test file (it shoud have 'compile-flags:-g' in the header)
266267 let mut ProcRes = compile_test( config, props, testfile) ;
267- if ProcRes . status != 0 {
268+ if ! ProcRes . status. success ( ) {
268269 fatal_ProcRes( ~"compilation failed!", & ProcRes) ;
269270 }
270271
@@ -375,7 +376,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
375376 }
376377 }
377378
378- if ProcRes.status != 0 {
379+ if ! ProcRes.status.success() {
379380 fatal(~" gdb failed to execute");
380381 }
381382 let num_check_lines = check_lines.len();
@@ -431,7 +432,7 @@ fn check_error_patterns(props: &TestProps,
431432 }
432433 }
433434
434- if ProcRes.status == 0 {
435+ if ProcRes.status.success() {
435436 fatal(~" process did not return an error status");
436437 }
437438
@@ -473,7 +474,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
473474 let mut found_flags = vec::from_elem(
474475 expected_errors.len(), false);
475476
476- if ProcRes.status == 0 {
477+ if ProcRes.status.success() {
477478 fatal(~" process did not return an error status");
478479 }
479480
@@ -625,7 +626,7 @@ fn scan_string(haystack: &str, needle: &str, idx: &mut uint) -> bool {
625626
626627struct ProcArgs {prog: ~str, args: ~[~str]}
627628
628- struct ProcRes {status: int , stdout: ~str, stderr: ~str, cmdline: ~str}
629+ struct ProcRes {status: ProcessExit , stdout: ~str, stderr: ~str, cmdline: ~str}
629630
630631fn compile_test(config: &config, props: &TestProps,
631632 testfile: &Path) -> ProcRes {
@@ -692,7 +693,7 @@ fn compose_and_run_compiler(
692693 |a,b| make_lib_name(a, b, testfile), &abs_ab);
693694 let auxres = compose_and_run(config, &abs_ab, aux_args, ~[],
694695 config.compile_lib_path, None);
695- if auxres.status != 0 {
696+ if ! auxres.status.success() {
696697 fatal_ProcRes(
697698 format!(" auxiliary build of { } failed to compile: ",
698699 abs_ab.display()),
@@ -966,7 +967,12 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
966967
967968 dump_output(config, testfile, stdout_out, stderr_out);
968969
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+ }
970976}
971977
972978fn _dummy_exec_compiled_test(config: &config, props: &TestProps,
@@ -976,9 +982,9 @@ fn _dummy_exec_compiled_test(config: &config, props: &TestProps,
976982 let cmdline = make_cmdline(" ", args.prog, args.args);
977983
978984 match config.mode {
979- mode_run_fail => ProcRes {status: 101, stdout: ~" ",
985+ mode_run_fail => ProcRes {status: process::ExitStatus( 101) , stdout: ~" ",
980986 stderr: ~" ", cmdline: cmdline},
981- _ => ProcRes {status: 0 , stdout: ~" ",
987+ _ => ProcRes {status: process::ExitStatus(0) , stdout: ~" ",
982988 stderr: ~" ", cmdline: cmdline}
983989 }
984990}
@@ -1099,33 +1105,33 @@ fn run_codegen_test(config: &config, props: &TestProps,
10991105 }
11001106
11011107 let mut ProcRes = compile_test_and_save_bitcode(config, props, testfile);
1102- if ProcRes.status != 0 {
1108+ if ! ProcRes.status.success() {
11031109 fatal_ProcRes(~" compilation failed!", &ProcRes);
11041110 }
11051111
11061112 ProcRes = extract_function_from_bitcode(config, props, " test", testfile, " ");
1107- if ProcRes.status != 0 {
1113+ if ! ProcRes.status.success() {
11081114 fatal_ProcRes(~" extracting ' test' function failed", &ProcRes);
11091115 }
11101116
11111117 ProcRes = disassemble_extract(config, props, testfile, " ");
1112- if ProcRes.status != 0 {
1118+ if ! ProcRes.status.success() {
11131119 fatal_ProcRes(~" disassembling extract failed", &ProcRes);
11141120 }
11151121
11161122
11171123 let mut ProcRes = compile_cc_with_clang_and_save_bitcode(config, props, testfile);
1118- if ProcRes.status != 0 {
1124+ if ! ProcRes.status.success() {
11191125 fatal_ProcRes(~" compilation failed!", &ProcRes);
11201126 }
11211127
11221128 ProcRes = extract_function_from_bitcode(config, props, " test", testfile, " clang");
1123- if ProcRes.status != 0 {
1129+ if ! ProcRes.status.success() {
11241130 fatal_ProcRes(~" extracting ' test' function failed", &ProcRes);
11251131 }
11261132
11271133 ProcRes = disassemble_extract(config, props, testfile, " clang");
1128- if ProcRes.status != 0 {
1134+ if ! ProcRes.status.success() {
11291135 fatal_ProcRes(~" disassembling extract failed", &ProcRes);
11301136 }
11311137
0 commit comments