@@ -325,39 +325,26 @@ impl<'test> TestCx<'test> {
325
325
}
326
326
}
327
327
328
- fn print_source ( & self ,
329
- src : String ,
330
- pretty_type : & str )
331
- -> ProcRes {
328
+ fn print_source ( & self , src : String , pretty_type : & str ) -> ProcRes {
332
329
let aux_dir = self . aux_output_dir_name ( ) ;
333
- self . compose_and_run ( self . make_pp_args ( pretty_type. to_owned ( ) ) ,
330
+
331
+ let mut rustc = Command :: new ( & self . config . rustc_path ) ;
332
+ rustc. arg ( "-" )
333
+ . arg ( "-Zunstable-options" )
334
+ . args ( & [ "--unpretty" , & pretty_type] )
335
+ . args ( & [ "--target" , & self . config . target ] )
336
+ . arg ( "-L" ) . arg ( & aux_dir)
337
+ . args ( self . split_maybe_args ( & self . config . target_rustcflags ) )
338
+ . args ( & self . props . compile_flags ) ;
339
+
340
+ self . compose_and_run ( rustc,
334
341
self . props . exec_env . clone ( ) ,
335
342
self . config . compile_lib_path . to_str ( ) . unwrap ( ) ,
336
343
Some ( aux_dir. to_str ( ) . unwrap ( ) ) ,
337
344
Some ( src) ,
338
345
None )
339
346
}
340
347
341
- fn make_pp_args ( & self ,
342
- pretty_type : String )
343
- -> ProcArgs {
344
- let aux_dir = self . aux_output_dir_name ( ) ;
345
- // FIXME (#9639): This needs to handle non-utf8 paths
346
- let mut args = vec ! [ "-" . to_owned( ) ,
347
- "-Zunstable-options" . to_owned( ) ,
348
- "--unpretty" . to_owned( ) ,
349
- pretty_type,
350
- format!( "--target={}" , self . config. target) ,
351
- "-L" . to_owned( ) ,
352
- aux_dir. to_str( ) . unwrap( ) . to_owned( ) ] ;
353
- args. extend ( self . split_maybe_args ( & self . config . target_rustcflags ) ) ;
354
- args. extend ( self . props . compile_flags . iter ( ) . cloned ( ) ) ;
355
- ProcArgs {
356
- prog : self . config . rustc_path . to_str ( ) . unwrap ( ) . to_owned ( ) ,
357
- args,
358
- }
359
- }
360
-
361
348
fn compare_source ( & self ,
362
349
expected : & str ,
363
350
actual : & str ) {
@@ -562,9 +549,9 @@ actual:\n\
562
549
. output ( )
563
550
. expect ( & format ! ( "failed to exec `{:?}`" , gdb_path) ) ;
564
551
let cmdline = {
565
- let cmdline = self . make_cmdline ( "" ,
566
- & format ! ( "{}- gdb" , self . config . target ) ,
567
- & debugger_opts ) ;
552
+ let mut gdb = Command :: new ( & format ! ( "{}-gdb" , self . config . target ) ) ;
553
+ gdb. args ( & debugger_opts ) ;
554
+ let cmdline = self . make_cmdline ( & gdb , "" ) ;
568
555
logv ( self . config , format ! ( "executing {}" , cmdline) ) ;
569
556
cmdline
570
557
} ;
@@ -654,15 +641,13 @@ actual:\n\
654
641
"-nx" . to_owned( ) ,
655
642
format!( "-command={}" , debugger_script. to_str( ) . unwrap( ) ) ] ;
656
643
657
- let proc_args = ProcArgs {
658
- prog : self . config . gdb . as_ref ( ) . unwrap ( ) . to_owned ( ) ,
659
- args : debugger_opts,
660
- } ;
644
+ let mut gdb = Command :: new ( self . config . gdb . as_ref ( ) . unwrap ( ) ) ;
645
+ gdb. args ( & debugger_opts) ;
661
646
662
647
let environment = vec ! [ ( "PYTHONPATH" . to_owned( ) , rust_pp_module_abs_path) ] ;
663
648
664
649
debugger_run_result =
665
- self . compose_and_run ( proc_args ,
650
+ self . compose_and_run ( gdb ,
666
651
environment,
667
652
self . config . run_lib_path . to_str ( ) . unwrap ( ) ,
668
653
None ,
@@ -1205,23 +1190,22 @@ actual:\n\
1205
1190
// the process) and then report back the same result.
1206
1191
_ if self . config . remote_test_client . is_some ( ) => {
1207
1192
let aux_dir = self . aux_output_dir_name ( ) ;
1208
- let mut args = self . make_run_args ( ) ;
1209
- let mut program = args. prog . clone ( ) ;
1193
+ let ProcArgs { mut prog, args } = self . make_run_args ( ) ;
1210
1194
if let Ok ( entries) = aux_dir. read_dir ( ) {
1211
1195
for entry in entries {
1212
1196
let entry = entry. unwrap ( ) ;
1213
1197
if !entry. path ( ) . is_file ( ) {
1214
1198
continue
1215
1199
}
1216
- program . push_str ( ":" ) ;
1217
- program . push_str ( entry. path ( ) . to_str ( ) . unwrap ( ) ) ;
1200
+ prog . push_str ( ":" ) ;
1201
+ prog . push_str ( entry. path ( ) . to_str ( ) . unwrap ( ) ) ;
1218
1202
}
1219
1203
}
1220
- args . args . insert ( 0 , program ) ;
1221
- args . args . insert ( 0 , "run" . to_string ( ) ) ;
1222
- args . prog = self . config . remote_test_client . clone ( ) . unwrap ( )
1223
- . into_os_string ( ) . into_string ( ) . unwrap ( ) ;
1224
- self . compose_and_run ( args ,
1204
+ let mut test_client = Command :: new (
1205
+ self . config . remote_test_client . as_ref ( ) . unwrap ( ) ) ;
1206
+ test_client . args ( & [ "run" , & prog ] ) ;
1207
+ test_client . args ( args ) ;
1208
+ self . compose_and_run ( test_client ,
1225
1209
env,
1226
1210
self . config . run_lib_path . to_str ( ) . unwrap ( ) ,
1227
1211
Some ( aux_dir. to_str ( ) . unwrap ( ) ) ,
@@ -1234,7 +1218,10 @@ actual:\n\
1234
1218
Some ( self . output_base_name ( )
1235
1219
. parent ( ) . unwrap ( )
1236
1220
. to_str ( ) . unwrap ( ) . to_owned ( ) ) ;
1237
- self . compose_and_run ( self . make_run_args ( ) ,
1221
+ let ProcArgs { prog, args } = self . make_run_args ( ) ;
1222
+ let mut program = Command :: new ( & prog) ;
1223
+ program. args ( args) ;
1224
+ self . compose_and_run ( program,
1238
1225
env,
1239
1226
self . config . run_lib_path . to_str ( ) . unwrap ( ) ,
1240
1227
Some ( aux_dir. to_str ( ) . unwrap ( ) ) ,
@@ -1312,8 +1299,11 @@ actual:\n\
1312
1299
testpaths : & aux_testpaths,
1313
1300
revision : self . revision
1314
1301
} ;
1315
- let aux_args = aux_cx. make_compile_args ( crate_type, & aux_testpaths. file , aux_output) ;
1316
- let auxres = aux_cx. compose_and_run ( aux_args,
1302
+ let ProcArgs { prog, args } =
1303
+ aux_cx. make_compile_args ( crate_type, & aux_testpaths. file , aux_output) ;
1304
+ let mut rustc = Command :: new ( prog) ;
1305
+ rustc. args ( & args) ;
1306
+ let auxres = aux_cx. compose_and_run ( rustc,
1317
1307
Vec :: new ( ) ,
1318
1308
aux_cx. config . compile_lib_path . to_str ( ) . unwrap ( ) ,
1319
1309
Some ( aux_dir. to_str ( ) . unwrap ( ) ) ,
@@ -1327,7 +1317,11 @@ actual:\n\
1327
1317
}
1328
1318
}
1329
1319
1330
- self . compose_and_run ( args,
1320
+ let ProcArgs { prog, args } = args;
1321
+ let mut rustc = Command :: new ( prog) ;
1322
+ rustc. args ( args) ;
1323
+
1324
+ self . compose_and_run ( rustc,
1331
1325
self . props . rustc_env . clone ( ) ,
1332
1326
self . config . compile_lib_path . to_str ( ) . unwrap ( ) ,
1333
1327
Some ( aux_dir. to_str ( ) . unwrap ( ) ) ,
@@ -1336,37 +1330,33 @@ actual:\n\
1336
1330
}
1337
1331
1338
1332
fn compose_and_run ( & self ,
1339
- ProcArgs { args , prog } : ProcArgs ,
1333
+ mut command : Command ,
1340
1334
procenv : Vec < ( String , String ) > ,
1341
1335
lib_path : & str ,
1342
1336
aux_path : Option < & str > ,
1343
1337
input : Option < String > ,
1344
1338
working_dir : Option < String > ) -> ProcRes {
1345
1339
let cmdline =
1346
1340
{
1347
- let cmdline = self . make_cmdline ( lib_path,
1348
- & prog,
1349
- & args) ;
1341
+ let cmdline = self . make_cmdline ( & command, lib_path) ;
1350
1342
logv ( self . config , format ! ( "executing {}" , cmdline) ) ;
1351
1343
cmdline
1352
1344
} ;
1353
1345
1354
- let mut process = Command :: new ( & prog) ;
1355
- process
1356
- . args ( & args)
1346
+ command
1357
1347
. stdout ( Stdio :: piped ( ) )
1358
1348
. stderr ( Stdio :: piped ( ) )
1359
1349
. stdin ( Stdio :: piped ( ) ) ;
1360
1350
1361
- procsrv:: add_target_env ( & mut process , lib_path, aux_path) ;
1351
+ procsrv:: add_target_env ( & mut command , lib_path, aux_path) ;
1362
1352
for ( key, val) in procenv {
1363
- process . env ( & key, & val) ;
1353
+ command . env ( & key, & val) ;
1364
1354
}
1365
1355
if let Some ( cwd) = working_dir {
1366
- process . current_dir ( cwd) ;
1356
+ command . current_dir ( cwd) ;
1367
1357
}
1368
1358
1369
- let mut child = process . spawn ( ) . expect ( & format ! ( "failed to exec `{}`" , prog ) ) ;
1359
+ let mut child = command . spawn ( ) . expect ( & format ! ( "failed to exec `{:? }`" , & command ) ) ;
1370
1360
if let Some ( input) = input {
1371
1361
child. stdin . as_mut ( ) . unwrap ( ) . write_all ( input. as_bytes ( ) ) . unwrap ( ) ;
1372
1362
}
@@ -1568,20 +1558,20 @@ actual:\n\
1568
1558
}
1569
1559
}
1570
1560
1571
- fn make_cmdline ( & self , libpath : & str , prog : & str , args : & [ String ] ) -> String {
1561
+ fn make_cmdline ( & self , command : & Command , libpath : & str ) -> String {
1572
1562
use util;
1573
1563
1574
1564
// Linux and mac don't require adjusting the library search path
1575
1565
if cfg ! ( unix) {
1576
- format ! ( "{} {} " , prog , args . join ( " " ) )
1566
+ format ! ( "{:?} " , command )
1577
1567
} else {
1578
1568
// Build the LD_LIBRARY_PATH variable as it would be seen on the command line
1579
1569
// for diagnostic purposes
1580
1570
fn lib_path_cmd_prefix ( path : & str ) -> String {
1581
1571
format ! ( "{}=\" {}\" " , util:: lib_path_env_var( ) , util:: make_new_path( path) )
1582
1572
}
1583
1573
1584
- format ! ( "{} {} {} " , lib_path_cmd_prefix( libpath) , prog , args . join ( " " ) )
1574
+ format ! ( "{} {:?} " , lib_path_cmd_prefix( libpath) , command )
1585
1575
}
1586
1576
}
1587
1577
@@ -1715,14 +1705,11 @@ actual:\n\
1715
1705
1716
1706
fn check_ir_with_filecheck ( & self ) -> ProcRes {
1717
1707
let irfile = self . output_base_name ( ) . with_extension ( "ll" ) ;
1718
- let prog = self . config . llvm_filecheck . as_ref ( ) . unwrap ( ) ;
1719
- let proc_args = ProcArgs {
1720
- // FIXME (#9639): This needs to handle non-utf8 paths
1721
- prog : prog. to_str ( ) . unwrap ( ) . to_owned ( ) ,
1722
- args : vec ! [ format!( "-input-file={}" , irfile. to_str( ) . unwrap( ) ) ,
1723
- self . testpaths. file. to_str( ) . unwrap( ) . to_owned( ) ]
1724
- } ;
1725
- self . compose_and_run ( proc_args, Vec :: new ( ) , "" , None , None , None )
1708
+ let mut filecheck = Command :: new ( self . config . llvm_filecheck . as_ref ( ) . unwrap ( ) ) ;
1709
+ // FIXME (#9639): This needs to handle non-utf8 paths
1710
+ filecheck. arg ( & format ! ( "-input-file={}" , irfile. to_str( ) . unwrap( ) ) ) ;
1711
+ filecheck. arg ( & self . testpaths . file ) ;
1712
+ self . compose_and_run ( filecheck, Vec :: new ( ) , "" , None , None , None )
1726
1713
}
1727
1714
1728
1715
fn run_codegen_test ( & self ) {
0 commit comments