Skip to content

Commit 514b37e

Browse files
committed
refactor interface of make_compile_args
1 parent 102bab3 commit 514b37e

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,8 @@ fn compile_test(config: &Config, props: &TestProps,
11611161
let args = make_compile_args(config,
11621162
props,
11631163
link_args,
1164-
|a, b| TargetLocation::ThisFile(make_exe_name(a, b)), testpaths);
1164+
&testpaths.file,
1165+
TargetLocation::ThisFile(make_exe_name(config, testpaths)));
11651166
compose_and_run_compiler(config, props, testpaths, args, None)
11661167
}
11671168

@@ -1270,16 +1271,17 @@ fn compose_and_run_compiler(config: &Config, props: &TestProps,
12701271
}
12711272
};
12721273
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+
};
12731279
let aux_args =
12741280
make_compile_args(config,
12751281
&aux_props,
12761282
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);
12831285
let auxres = compose_and_run(config,
12841286
&aux_testpaths,
12851287
aux_args,
@@ -1328,22 +1330,21 @@ enum TargetLocation {
13281330
ThisDirectory(PathBuf),
13291331
}
13301332

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
13381339
{
1339-
let xform_file = xform(config, testpaths);
13401340
let target = if props.force_host {
13411341
&*config.host
13421342
} else {
13431343
&*config.target
13441344
};
1345+
13451346
// 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(),
13471348
"-L".to_owned(),
13481349
config.build_base.to_str().unwrap().to_owned(),
13491350
format!("--target={}", target));
@@ -1384,7 +1385,7 @@ fn make_compile_args<F>(config: &Config,
13841385
args.push("-C".to_owned());
13851386
args.push("prefer-dynamic".to_owned());
13861387
}
1387-
let path = match xform_file {
1388+
let path = match output_file {
13881389
TargetLocation::ThisFile(path) => {
13891390
args.push("-o".to_owned());
13901391
path
@@ -1550,6 +1551,9 @@ fn output_testname(filepath: &Path) -> PathBuf {
15501551
PathBuf::from(filepath.file_stem().unwrap())
15511552
}
15521553

1554+
/// Given a test path like `compile-fail/foo/bar.rs` Returns a name like
1555+
///
1556+
/// <output>/foo/bar-stage1
15531557
fn output_base_name(config: &Config, testpaths: &TestPaths) -> PathBuf {
15541558
let dir = config.build_base.join(&testpaths.relative_dir);
15551559

@@ -1772,10 +1776,11 @@ fn compile_test_and_save_ir(config: &Config, props: &TestProps,
17721776
let args = make_compile_args(config,
17731777
props,
17741778
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()));
17791784
compose_and_run_compiler(config, props, testpaths, args, None)
17801785
}
17811786

0 commit comments

Comments
 (0)