@@ -71,14 +71,6 @@ pub fn run_metrics(config: Config, testfile: String, mm: &mut MetricMap) {
71
71
}
72
72
}
73
73
74
- fn get_output ( props : & TestProps , proc_res : & ProcRes ) -> String {
75
- if props. check_stdout {
76
- format ! ( "{}{}" , proc_res. stdout, proc_res. stderr)
77
- } else {
78
- proc_res. stderr . clone ( )
79
- }
80
- }
81
-
82
74
fn run_cfail_test ( config : & Config , props : & TestProps , testfile : & Path ) {
83
75
let proc_res = compile_test ( config, props, testfile) ;
84
76
@@ -89,22 +81,16 @@ fn run_cfail_test(config: &Config, props: &TestProps, testfile: &Path) {
89
81
90
82
check_correct_failure_status ( & proc_res) ;
91
83
92
- if proc_res. status . success ( ) {
93
- fatal ( "process did not return an error status" ) ;
94
- }
95
-
96
- let output_to_check = get_output ( props, & proc_res) ;
97
84
let expected_errors = errors:: load_errors ( & config. cfail_regex , testfile) ;
98
85
if !expected_errors. is_empty ( ) {
99
86
if !props. error_patterns . is_empty ( ) {
100
87
fatal ( "both error pattern and expected errors specified" ) ;
101
88
}
102
89
check_expected_errors ( expected_errors, testfile, & proc_res) ;
103
90
} else {
104
- check_error_patterns ( props, testfile, output_to_check . as_slice ( ) , & proc_res) ;
91
+ check_error_patterns ( props, testfile, & proc_res) ;
105
92
}
106
93
check_no_compiler_crash ( & proc_res) ;
107
- check_forbid_output ( props, output_to_check. as_slice ( ) , & proc_res) ;
108
94
}
109
95
110
96
fn run_rfail_test ( config : & Config , props : & TestProps , testfile : & Path ) {
@@ -126,9 +112,8 @@ fn run_rfail_test(config: &Config, props: &TestProps, testfile: &Path) {
126
112
fatal_proc_rec ( "run-fail test isn't valgrind-clean!" , & proc_res) ;
127
113
}
128
114
129
- let output_to_check = get_output ( props, & proc_res) ;
130
115
check_correct_failure_status ( & proc_res) ;
131
- check_error_patterns ( props, testfile, output_to_check . as_slice ( ) , & proc_res) ;
116
+ check_error_patterns ( props, testfile, & proc_res) ;
132
117
}
133
118
134
119
fn check_correct_failure_status ( proc_res : & ProcRes ) {
@@ -273,8 +258,8 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
273
258
format!( "--target={}" , config. target) ,
274
259
"-L" . to_string( ) ,
275
260
aux_dir. as_str( ) . unwrap( ) . to_string( ) ) ;
276
- args. extend ( split_maybe_args ( & config. target_rustcflags ) . into_iter ( ) ) ;
277
- args. extend ( split_maybe_args ( & props. compile_flags ) . into_iter ( ) ) ;
261
+ args. push_all_move ( split_maybe_args ( & config. target_rustcflags ) ) ;
262
+ args. push_all_move ( split_maybe_args ( & props. compile_flags ) ) ;
278
263
return ProcArgs {
279
264
prog : config. rustc_path . as_str ( ) . unwrap ( ) . to_string ( ) ,
280
265
args : args,
@@ -321,8 +306,8 @@ actual:\n\
321
306
config. build_base. as_str( ) . unwrap( ) . to_string( ) ,
322
307
"-L" . to_string( ) ,
323
308
aux_dir. as_str( ) . unwrap( ) . to_string( ) ) ;
324
- args. extend ( split_maybe_args ( & config. target_rustcflags ) . into_iter ( ) ) ;
325
- args. extend ( split_maybe_args ( & props. compile_flags ) . into_iter ( ) ) ;
309
+ args. push_all_move ( split_maybe_args ( & config. target_rustcflags ) ) ;
310
+ args. push_all_move ( split_maybe_args ( & props. compile_flags ) ) ;
326
311
// FIXME (#9639): This needs to handle non-utf8 paths
327
312
return ProcArgs {
328
313
prog : config. rustc_path . as_str ( ) . unwrap ( ) . to_string ( ) ,
@@ -444,8 +429,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
444
429
"-nx" . to_string( ) ,
445
430
format!( "-command={}" , debugger_script. as_str( ) . unwrap( ) ) ) ;
446
431
447
- let mut gdb_path = tool_path;
448
- gdb_path. push_str ( "/bin/arm-linux-androideabi-gdb" ) ;
432
+ let gdb_path = tool_path. append ( "/bin/arm-linux-androideabi-gdb" ) ;
449
433
let procsrv:: Result {
450
434
out,
451
435
err,
@@ -850,15 +834,24 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
850
834
851
835
fn check_error_patterns ( props : & TestProps ,
852
836
testfile : & Path ,
853
- output_to_check : & str ,
854
837
proc_res : & ProcRes ) {
855
838
if props. error_patterns . is_empty ( ) {
856
839
fatal ( format ! ( "no error pattern specified in {}" ,
857
840
testfile. display( ) ) . as_slice ( ) ) ;
858
841
}
842
+
843
+ if proc_res. status . success ( ) {
844
+ fatal ( "process did not return an error status" ) ;
845
+ }
846
+
859
847
let mut next_err_idx = 0 u;
860
848
let mut next_err_pat = & props. error_patterns [ next_err_idx] ;
861
849
let mut done = false ;
850
+ let output_to_check = if props. check_stdout {
851
+ format ! ( "{}{}" , proc_res. stdout, proc_res. stderr)
852
+ } else {
853
+ proc_res. stderr . clone ( )
854
+ } ;
862
855
for line in output_to_check. as_slice ( ) . lines ( ) {
863
856
if line. contains ( next_err_pat. as_slice ( ) ) {
864
857
debug ! ( "found error pattern {}" , next_err_pat) ;
@@ -897,16 +890,6 @@ fn check_no_compiler_crash(proc_res: &ProcRes) {
897
890
}
898
891
}
899
892
900
- fn check_forbid_output ( props : & TestProps ,
901
- output_to_check : & str ,
902
- proc_res : & ProcRes ) {
903
- for pat in props. forbid_output . iter ( ) {
904
- if output_to_check. contains ( pat. as_slice ( ) ) {
905
- fatal_proc_rec ( "forbidden pattern found in compiler output" , proc_res) ;
906
- }
907
- }
908
- }
909
-
910
893
fn check_expected_errors ( expected_errors : Vec < errors:: ExpectedError > ,
911
894
testfile : & Path ,
912
895
proc_res : & ProcRes ) {
@@ -1096,12 +1079,11 @@ fn compile_test_(config: &Config, props: &TestProps,
1096
1079
testfile : & Path , extra_args : & [ String ] ) -> ProcRes {
1097
1080
let aux_dir = aux_output_dir_name ( config, testfile) ;
1098
1081
// FIXME (#9639): This needs to handle non-utf8 paths
1099
- let mut link_args = vec ! ( "-L" . to_string( ) ,
1100
- aux_dir. as_str( ) . unwrap( ) . to_string( ) ) ;
1101
- link_args. extend ( extra_args. iter ( ) . map ( |s| s. clone ( ) ) ) ;
1082
+ let link_args = vec ! ( "-L" . to_string( ) ,
1083
+ aux_dir. as_str( ) . unwrap( ) . to_string( ) ) ;
1102
1084
let args = make_compile_args ( config,
1103
1085
props,
1104
- link_args,
1086
+ link_args. append ( extra_args ) ,
1105
1087
|a, b| ThisFile ( make_exe_name ( a, b) ) , testfile) ;
1106
1088
compose_and_run_compiler ( config, props, testfile, args, None )
1107
1089
}
@@ -1148,16 +1130,16 @@ fn compose_and_run_compiler(
1148
1130
for rel_ab in props. aux_builds . iter ( ) {
1149
1131
let abs_ab = config. aux_base . join ( rel_ab. as_slice ( ) ) ;
1150
1132
let aux_props = header:: load_props ( & abs_ab) ;
1151
- let mut crate_type = if aux_props. no_prefer_dynamic {
1133
+ let crate_type = if aux_props. no_prefer_dynamic {
1152
1134
Vec :: new ( )
1153
1135
} else {
1154
1136
vec ! ( "--crate-type=dylib" . to_string( ) )
1155
1137
} ;
1156
- crate_type. extend ( extra_link_args. clone ( ) . into_iter ( ) ) ;
1157
1138
let aux_args =
1158
1139
make_compile_args ( config,
1159
1140
& aux_props,
1160
- crate_type,
1141
+ crate_type. append (
1142
+ extra_link_args. as_slice ( ) ) ,
1161
1143
|a, b| {
1162
1144
let f = make_lib_name ( a, b, testfile) ;
1163
1145
ThisDirectory ( f. dir_path ( ) )
@@ -1248,11 +1230,11 @@ fn make_compile_args(config: &Config,
1248
1230
} ;
1249
1231
args. push ( path. as_str ( ) . unwrap ( ) . to_string ( ) ) ;
1250
1232
if props. force_host {
1251
- args. extend ( split_maybe_args ( & config. host_rustcflags ) . into_iter ( ) ) ;
1233
+ args. push_all_move ( split_maybe_args ( & config. host_rustcflags ) ) ;
1252
1234
} else {
1253
- args. extend ( split_maybe_args ( & config. target_rustcflags ) . into_iter ( ) ) ;
1235
+ args. push_all_move ( split_maybe_args ( & config. target_rustcflags ) ) ;
1254
1236
}
1255
- args. extend ( split_maybe_args ( & props. compile_flags ) . into_iter ( ) ) ;
1237
+ args. push_all_move ( split_maybe_args ( & props. compile_flags ) ) ;
1256
1238
return ProcArgs {
1257
1239
prog : config. rustc_path . as_str ( ) . unwrap ( ) . to_string ( ) ,
1258
1240
args : args,
@@ -1269,9 +1251,10 @@ fn make_lib_name(config: &Config, auxfile: &Path, testfile: &Path) -> Path {
1269
1251
fn make_exe_name ( config : & Config , testfile : & Path ) -> Path {
1270
1252
let mut f = output_base_name ( config, testfile) ;
1271
1253
if !os:: consts:: EXE_SUFFIX . is_empty ( ) {
1272
- let mut fname = f. filename ( ) . unwrap ( ) . to_vec ( ) ;
1273
- fname. extend ( os:: consts:: EXE_SUFFIX . bytes ( ) ) ;
1274
- f. set_filename ( fname) ;
1254
+ match f. filename ( ) . map ( |s| Vec :: from_slice ( s) . append ( os:: consts:: EXE_SUFFIX . as_bytes ( ) ) ) {
1255
+ Some ( v) => f. set_filename ( v) ,
1256
+ None => ( )
1257
+ }
1275
1258
}
1276
1259
f
1277
1260
}
@@ -1287,7 +1270,7 @@ fn make_run_args(config: &Config, props: &TestProps, testfile: &Path) ->
1287
1270
args. push ( exe_file. as_str ( ) . unwrap ( ) . to_string ( ) ) ;
1288
1271
1289
1272
// Add the arguments in the run_flags directive
1290
- args. extend ( split_maybe_args ( & props. run_flags ) . into_iter ( ) ) ;
1273
+ args. push_all_move ( split_maybe_args ( & props. run_flags ) ) ;
1291
1274
1292
1275
let prog = args. remove ( 0 ) . unwrap ( ) ;
1293
1276
return ProcArgs {
@@ -1382,10 +1365,12 @@ fn make_out_name(config: &Config, testfile: &Path, extension: &str) -> Path {
1382
1365
}
1383
1366
1384
1367
fn aux_output_dir_name ( config : & Config , testfile : & Path ) -> Path {
1385
- let f = output_base_name ( config, testfile) ;
1386
- let mut fname = f. filename ( ) . unwrap ( ) . to_vec ( ) ;
1387
- fname. extend ( "libaux" . bytes ( ) ) ;
1388
- f. with_filename ( fname)
1368
+ let mut f = output_base_name ( config, testfile) ;
1369
+ match f. filename ( ) . map ( |s| Vec :: from_slice ( s) . append ( b".libaux" ) ) {
1370
+ Some ( v) => f. set_filename ( v) ,
1371
+ None => ( )
1372
+ }
1373
+ f
1389
1374
}
1390
1375
1391
1376
fn output_testname ( testfile : & Path ) -> Path {
@@ -1597,25 +1582,22 @@ fn append_suffix_to_stem(p: &Path, suffix: &str) -> Path {
1597
1582
if suffix. len ( ) == 0 {
1598
1583
( * p) . clone ( )
1599
1584
} else {
1600
- let mut stem = p. filestem ( ) . unwrap ( ) . to_vec ( ) ;
1601
- stem. extend ( "-" . bytes ( ) ) ;
1602
- stem. extend ( suffix. bytes ( ) ) ;
1603
- p. with_filename ( stem)
1585
+ let stem = p. filestem ( ) . unwrap ( ) ;
1586
+ p. with_filename ( Vec :: from_slice ( stem) . append ( b"-" ) . append ( suffix. as_bytes ( ) ) )
1604
1587
}
1605
1588
}
1606
1589
1607
1590
fn compile_test_and_save_bitcode ( config : & Config , props : & TestProps ,
1608
1591
testfile : & Path ) -> ProcRes {
1609
1592
let aux_dir = aux_output_dir_name ( config, testfile) ;
1610
1593
// FIXME (#9639): This needs to handle non-utf8 paths
1611
- let mut link_args = vec ! ( "-L" . to_string( ) ,
1612
- aux_dir. as_str( ) . unwrap( ) . to_string( ) ) ;
1594
+ let link_args = vec ! ( "-L" . to_string( ) ,
1595
+ aux_dir. as_str( ) . unwrap( ) . to_string( ) ) ;
1613
1596
let llvm_args = vec ! ( "--emit=bc,obj" . to_string( ) ,
1614
1597
"--crate-type=lib" . to_string( ) ) ;
1615
- link_args. extend ( llvm_args. into_iter ( ) ) ;
1616
1598
let args = make_compile_args ( config,
1617
1599
props,
1618
- link_args,
1600
+ link_args. append ( llvm_args . as_slice ( ) ) ,
1619
1601
|a, b| ThisDirectory ( output_base_name ( a, b) . dir_path ( ) ) ,
1620
1602
testfile) ;
1621
1603
compose_and_run_compiler ( config, props, testfile, args, None )
0 commit comments