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