@@ -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 ( ) ,
@@ -849,15 +834,24 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
849
834
850
835
fn check_error_patterns ( props : & TestProps ,
851
836
testfile : & Path ,
852
- output_to_check : & str ,
853
837
proc_res : & ProcRes ) {
854
838
if props. error_patterns . is_empty ( ) {
855
839
fatal ( format ! ( "no error pattern specified in {}" ,
856
840
testfile. display( ) ) . as_slice ( ) ) ;
857
841
}
842
+
843
+ if proc_res. status . success ( ) {
844
+ fatal ( "process did not return an error status" ) ;
845
+ }
846
+
858
847
let mut next_err_idx = 0 u;
859
848
let mut next_err_pat = & props. error_patterns [ next_err_idx] ;
860
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
+ } ;
861
855
for line in output_to_check. as_slice ( ) . lines ( ) {
862
856
if line. contains ( next_err_pat. as_slice ( ) ) {
863
857
debug ! ( "found error pattern {}" , next_err_pat) ;
@@ -896,16 +890,6 @@ fn check_no_compiler_crash(proc_res: &ProcRes) {
896
890
}
897
891
}
898
892
899
- fn check_forbid_output ( props : & TestProps ,
900
- output_to_check : & str ,
901
- proc_res : & ProcRes ) {
902
- for pat in props. forbid_output . iter ( ) {
903
- if output_to_check. contains ( pat. as_slice ( ) ) {
904
- fatal_proc_rec ( "forbidden pattern found in compiler output" , proc_res) ;
905
- }
906
- }
907
- }
908
-
909
893
fn check_expected_errors ( expected_errors : Vec < errors:: ExpectedError > ,
910
894
testfile : & Path ,
911
895
proc_res : & ProcRes ) {
@@ -1095,12 +1079,11 @@ fn compile_test_(config: &Config, props: &TestProps,
1095
1079
testfile : & Path , extra_args : & [ String ] ) -> ProcRes {
1096
1080
let aux_dir = aux_output_dir_name ( config, testfile) ;
1097
1081
// FIXME (#9639): This needs to handle non-utf8 paths
1098
- let mut link_args = vec ! ( "-L" . to_string( ) ,
1099
- aux_dir. as_str( ) . unwrap( ) . to_string( ) ) ;
1100
- 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( ) ) ;
1101
1084
let args = make_compile_args ( config,
1102
1085
props,
1103
- link_args,
1086
+ link_args. append ( extra_args ) ,
1104
1087
|a, b| ThisFile ( make_exe_name ( a, b) ) , testfile) ;
1105
1088
compose_and_run_compiler ( config, props, testfile, args, None )
1106
1089
}
@@ -1147,16 +1130,16 @@ fn compose_and_run_compiler(
1147
1130
for rel_ab in props. aux_builds . iter ( ) {
1148
1131
let abs_ab = config. aux_base . join ( rel_ab. as_slice ( ) ) ;
1149
1132
let aux_props = header:: load_props ( & abs_ab) ;
1150
- let mut crate_type = if aux_props. no_prefer_dynamic {
1133
+ let crate_type = if aux_props. no_prefer_dynamic {
1151
1134
Vec :: new ( )
1152
1135
} else {
1153
1136
vec ! ( "--crate-type=dylib" . to_string( ) )
1154
1137
} ;
1155
- crate_type. extend ( extra_link_args. clone ( ) . into_iter ( ) ) ;
1156
1138
let aux_args =
1157
1139
make_compile_args ( config,
1158
1140
& aux_props,
1159
- crate_type,
1141
+ crate_type. append (
1142
+ extra_link_args. as_slice ( ) ) ,
1160
1143
|a, b| {
1161
1144
let f = make_lib_name ( a, b, testfile) ;
1162
1145
ThisDirectory ( f. dir_path ( ) )
@@ -1247,11 +1230,11 @@ fn make_compile_args(config: &Config,
1247
1230
} ;
1248
1231
args. push ( path. as_str ( ) . unwrap ( ) . to_string ( ) ) ;
1249
1232
if props. force_host {
1250
- args. extend ( split_maybe_args ( & config. host_rustcflags ) . into_iter ( ) ) ;
1233
+ args. push_all_move ( split_maybe_args ( & config. host_rustcflags ) ) ;
1251
1234
} else {
1252
- args. extend ( split_maybe_args ( & config. target_rustcflags ) . into_iter ( ) ) ;
1235
+ args. push_all_move ( split_maybe_args ( & config. target_rustcflags ) ) ;
1253
1236
}
1254
- args. extend ( split_maybe_args ( & props. compile_flags ) . into_iter ( ) ) ;
1237
+ args. push_all_move ( split_maybe_args ( & props. compile_flags ) ) ;
1255
1238
return ProcArgs {
1256
1239
prog : config. rustc_path . as_str ( ) . unwrap ( ) . to_string ( ) ,
1257
1240
args : args,
@@ -1268,9 +1251,10 @@ fn make_lib_name(config: &Config, auxfile: &Path, testfile: &Path) -> Path {
1268
1251
fn make_exe_name ( config : & Config , testfile : & Path ) -> Path {
1269
1252
let mut f = output_base_name ( config, testfile) ;
1270
1253
if !os:: consts:: EXE_SUFFIX . is_empty ( ) {
1271
- let mut fname = f. filename ( ) . unwrap ( ) . to_vec ( ) ;
1272
- fname. extend ( os:: consts:: EXE_SUFFIX . bytes ( ) ) ;
1273
- 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
+ }
1274
1258
}
1275
1259
f
1276
1260
}
@@ -1286,7 +1270,7 @@ fn make_run_args(config: &Config, props: &TestProps, testfile: &Path) ->
1286
1270
args. push ( exe_file. as_str ( ) . unwrap ( ) . to_string ( ) ) ;
1287
1271
1288
1272
// Add the arguments in the run_flags directive
1289
- args. extend ( split_maybe_args ( & props. run_flags ) . into_iter ( ) ) ;
1273
+ args. push_all_move ( split_maybe_args ( & props. run_flags ) ) ;
1290
1274
1291
1275
let prog = args. remove ( 0 ) . unwrap ( ) ;
1292
1276
return ProcArgs {
@@ -1381,10 +1365,12 @@ fn make_out_name(config: &Config, testfile: &Path, extension: &str) -> Path {
1381
1365
}
1382
1366
1383
1367
fn aux_output_dir_name ( config : & Config , testfile : & Path ) -> Path {
1384
- let f = output_base_name ( config, testfile) ;
1385
- let mut fname = f. filename ( ) . unwrap ( ) . to_vec ( ) ;
1386
- fname. extend ( "libaux" . bytes ( ) ) ;
1387
- 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
1388
1374
}
1389
1375
1390
1376
fn output_testname ( testfile : & Path ) -> Path {
@@ -1596,25 +1582,22 @@ fn append_suffix_to_stem(p: &Path, suffix: &str) -> Path {
1596
1582
if suffix. len ( ) == 0 {
1597
1583
( * p) . clone ( )
1598
1584
} else {
1599
- let mut stem = p. filestem ( ) . unwrap ( ) . to_vec ( ) ;
1600
- stem. extend ( "-" . bytes ( ) ) ;
1601
- stem. extend ( suffix. bytes ( ) ) ;
1602
- p. with_filename ( stem)
1585
+ let stem = p. filestem ( ) . unwrap ( ) ;
1586
+ p. with_filename ( Vec :: from_slice ( stem) . append ( b"-" ) . append ( suffix. as_bytes ( ) ) )
1603
1587
}
1604
1588
}
1605
1589
1606
1590
fn compile_test_and_save_bitcode ( config : & Config , props : & TestProps ,
1607
1591
testfile : & Path ) -> ProcRes {
1608
1592
let aux_dir = aux_output_dir_name ( config, testfile) ;
1609
1593
// FIXME (#9639): This needs to handle non-utf8 paths
1610
- let mut link_args = vec ! ( "-L" . to_string( ) ,
1611
- aux_dir. as_str( ) . unwrap( ) . to_string( ) ) ;
1594
+ let link_args = vec ! ( "-L" . to_string( ) ,
1595
+ aux_dir. as_str( ) . unwrap( ) . to_string( ) ) ;
1612
1596
let llvm_args = vec ! ( "--emit=bc,obj" . to_string( ) ,
1613
1597
"--crate-type=lib" . to_string( ) ) ;
1614
- link_args. extend ( llvm_args. into_iter ( ) ) ;
1615
1598
let args = make_compile_args ( config,
1616
1599
props,
1617
- link_args,
1600
+ link_args. append ( llvm_args . as_slice ( ) ) ,
1618
1601
|a, b| ThisDirectory ( output_base_name ( a, b) . dir_path ( ) ) ,
1619
1602
testfile) ;
1620
1603
compose_and_run_compiler ( config, props, testfile, args, None )
0 commit comments