@@ -1161,7 +1161,8 @@ fn compile_test(config: &Config, props: &TestProps,
1161
1161
let args = make_compile_args ( config,
1162
1162
props,
1163
1163
link_args,
1164
- |a, b| TargetLocation :: ThisFile ( make_exe_name ( a, b) ) , testpaths) ;
1164
+ & testpaths. file ,
1165
+ TargetLocation :: ThisFile ( make_exe_name ( config, testpaths) ) ) ;
1165
1166
compose_and_run_compiler ( config, props, testpaths, args, None )
1166
1167
}
1167
1168
@@ -1270,16 +1271,17 @@ fn compose_and_run_compiler(config: &Config, props: &TestProps,
1270
1271
}
1271
1272
} ;
1272
1273
crate_type. extend ( extra_link_args. clone ( ) ) ;
1274
+ let aux_output = {
1275
+ let f = make_lib_name ( config, & testpaths. file , testpaths) ;
1276
+ let parent = f. parent ( ) . unwrap ( ) ;
1277
+ TargetLocation :: ThisDirectory ( parent. to_path_buf ( ) )
1278
+ } ;
1273
1279
let aux_args =
1274
1280
make_compile_args ( config,
1275
1281
& aux_props,
1276
1282
crate_type,
1277
- |a, b| {
1278
- let f = make_lib_name ( a, & b. file , testpaths) ;
1279
- let parent = f. parent ( ) . unwrap ( ) ;
1280
- TargetLocation :: ThisDirectory ( parent. to_path_buf ( ) )
1281
- } ,
1282
- & aux_testpaths) ;
1283
+ & aux_testpaths. file ,
1284
+ aux_output) ;
1283
1285
let auxres = compose_and_run ( config,
1284
1286
& aux_testpaths,
1285
1287
aux_args,
@@ -1328,22 +1330,21 @@ enum TargetLocation {
1328
1330
ThisDirectory ( PathBuf ) ,
1329
1331
}
1330
1332
1331
- fn make_compile_args < F > ( config : & Config ,
1332
- props : & TestProps ,
1333
- extras : Vec < String > ,
1334
- xform : F ,
1335
- testpaths : & TestPaths )
1336
- -> ProcArgs where
1337
- F : FnOnce ( & Config , & TestPaths ) -> TargetLocation ,
1333
+ fn make_compile_args ( config : & Config ,
1334
+ props : & TestProps ,
1335
+ extras : Vec < String > ,
1336
+ input_file : & Path ,
1337
+ output_file : TargetLocation )
1338
+ -> ProcArgs
1338
1339
{
1339
- let xform_file = xform ( config, testpaths) ;
1340
1340
let target = if props. force_host {
1341
1341
& * config. host
1342
1342
} else {
1343
1343
& * config. target
1344
1344
} ;
1345
+
1345
1346
// FIXME (#9639): This needs to handle non-utf8 paths
1346
- let mut args = vec ! ( testpaths . file . to_str( ) . unwrap( ) . to_owned( ) ,
1347
+ let mut args = vec ! ( input_file . to_str( ) . unwrap( ) . to_owned( ) ,
1347
1348
"-L" . to_owned( ) ,
1348
1349
config. build_base. to_str( ) . unwrap( ) . to_owned( ) ,
1349
1350
format!( "--target={}" , target) ) ;
@@ -1384,7 +1385,7 @@ fn make_compile_args<F>(config: &Config,
1384
1385
args. push ( "-C" . to_owned ( ) ) ;
1385
1386
args. push ( "prefer-dynamic" . to_owned ( ) ) ;
1386
1387
}
1387
- let path = match xform_file {
1388
+ let path = match output_file {
1388
1389
TargetLocation :: ThisFile ( path) => {
1389
1390
args. push ( "-o" . to_owned ( ) ) ;
1390
1391
path
@@ -1550,6 +1551,9 @@ fn output_testname(filepath: &Path) -> PathBuf {
1550
1551
PathBuf :: from ( filepath. file_stem ( ) . unwrap ( ) )
1551
1552
}
1552
1553
1554
+ /// Given a test path like `compile-fail/foo/bar.rs` Returns a name like
1555
+ ///
1556
+ /// <output>/foo/bar-stage1
1553
1557
fn output_base_name ( config : & Config , testpaths : & TestPaths ) -> PathBuf {
1554
1558
let dir = config. build_base . join ( & testpaths. relative_dir ) ;
1555
1559
@@ -1772,10 +1776,11 @@ fn compile_test_and_save_ir(config: &Config, props: &TestProps,
1772
1776
let args = make_compile_args ( config,
1773
1777
props,
1774
1778
link_args,
1775
- |a, b| TargetLocation :: ThisDirectory (
1776
- output_base_name ( a, b) . parent ( )
1777
- . unwrap ( ) . to_path_buf ( ) ) ,
1778
- testpaths) ;
1779
+ & testpaths. file ,
1780
+ TargetLocation :: ThisDirectory (
1781
+ output_base_name ( config, testpaths) . parent ( )
1782
+ . unwrap ( )
1783
+ . to_path_buf ( ) ) ) ;
1779
1784
compose_and_run_compiler ( config, props, testpaths, args, None )
1780
1785
}
1781
1786
0 commit comments