Skip to content

Commit 6dfc82b

Browse files
committed
Remove some parameters that are always self.testpaths
In particular, this eliminates the cryptic `of: &TestPaths` parameters.
1 parent c627945 commit 6dfc82b

File tree

7 files changed

+35
-44
lines changed

7 files changed

+35
-44
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ impl<'test> TestCx<'test> {
562562
self.maybe_add_external_args(&mut rustc, &self.config.target_rustcflags);
563563
rustc.args(&self.props.compile_flags);
564564

565-
self.compose_and_run_compiler(rustc, Some(src), self.testpaths)
565+
self.compose_and_run_compiler(rustc, Some(src))
566566
}
567567

568568
fn maybe_add_external_args(&self, cmd: &mut Command, args: &Vec<String>) {
@@ -993,18 +993,13 @@ impl<'test> TestCx<'test> {
993993
passes,
994994
);
995995

996-
self.compose_and_run_compiler(rustc, None, self.testpaths)
996+
self.compose_and_run_compiler(rustc, None)
997997
}
998998

999999
/// `root_out_dir` and `root_testpaths` refer to the parameters of the actual test being run.
10001000
/// Auxiliaries, no matter how deep, have the same root_out_dir and root_testpaths.
1001-
fn document(
1002-
&self,
1003-
root_out_dir: &Utf8Path,
1004-
root_testpaths: &TestPaths,
1005-
kind: DocKind,
1006-
) -> ProcRes {
1007-
self.document_inner(&self.testpaths.file, root_out_dir, root_testpaths, kind)
1001+
fn document(&self, root_out_dir: &Utf8Path, kind: DocKind) -> ProcRes {
1002+
self.document_inner(&self.testpaths.file, root_out_dir, kind)
10081003
}
10091004

10101005
/// Like `document`, but takes an explicit `file_to_doc` argument so that
@@ -1014,14 +1009,13 @@ impl<'test> TestCx<'test> {
10141009
&self,
10151010
file_to_doc: &Utf8Path,
10161011
root_out_dir: &Utf8Path,
1017-
root_testpaths: &TestPaths,
10181012
kind: DocKind,
10191013
) -> ProcRes {
10201014
if self.props.build_aux_docs {
10211015
assert_eq!(kind, DocKind::Html, "build-aux-docs only make sense for html output");
10221016

10231017
for rel_ab in &self.props.aux.builds {
1024-
let aux_path = self.compute_aux_test_paths(root_testpaths, rel_ab);
1018+
let aux_path = self.compute_aux_test_paths(rel_ab);
10251019
let props_for_aux = self.props.from_aux_file(&aux_path, self.revision, self.config);
10261020
let aux_cx = TestCx {
10271021
config: self.config,
@@ -1033,9 +1027,7 @@ impl<'test> TestCx<'test> {
10331027
};
10341028
// Create the directory for the stdout/stderr files.
10351029
create_dir_all(aux_cx.output_base_dir()).unwrap();
1036-
// use root_testpaths here, because aux-builds should have the
1037-
// same --out-dir and auxiliary directory.
1038-
let auxres = aux_cx.document_inner(&aux_path, &root_out_dir, root_testpaths, kind);
1030+
let auxres = aux_cx.document_inner(&aux_path, &root_out_dir, kind);
10391031
if !auxres.status.success() {
10401032
return auxres;
10411033
}
@@ -1063,7 +1055,7 @@ impl<'test> TestCx<'test> {
10631055
};
10641056

10651057
let mut rustdoc = Command::new(rustdoc_path);
1066-
let current_dir = output_base_dir(self.config, root_testpaths, self.safe_revision());
1058+
let current_dir = self.output_base_dir();
10671059
rustdoc.current_dir(current_dir);
10681060
rustdoc
10691061
.arg("-L")
@@ -1091,7 +1083,7 @@ impl<'test> TestCx<'test> {
10911083
rustdoc.arg(format!("-Clinker={}", linker));
10921084
}
10931085

1094-
self.compose_and_run_compiler(rustdoc, None, root_testpaths)
1086+
self.compose_and_run_compiler(rustdoc, None)
10951087
}
10961088

10971089
fn exec_compiled_test(&self) -> ProcRes {
@@ -1206,9 +1198,14 @@ impl<'test> TestCx<'test> {
12061198

12071199
/// For each `aux-build: foo/bar` annotation, we check to find the file in an `auxiliary`
12081200
/// directory relative to the test itself (not any intermediate auxiliaries).
1209-
fn compute_aux_test_paths(&self, of: &TestPaths, rel_ab: &str) -> Utf8PathBuf {
1210-
let test_ab =
1211-
of.file.parent().expect("test file path has no parent").join("auxiliary").join(rel_ab);
1201+
fn compute_aux_test_paths(&self, rel_ab: &str) -> Utf8PathBuf {
1202+
let test_ab = self
1203+
.testpaths
1204+
.file
1205+
.parent()
1206+
.expect("test file path has no parent")
1207+
.join("auxiliary")
1208+
.join(rel_ab);
12121209
if !test_ab.exists() {
12131210
self.fatal(&format!("aux-build `{}` source not found", test_ab))
12141211
}
@@ -1259,13 +1256,13 @@ impl<'test> TestCx<'test> {
12591256
aux_dir
12601257
}
12611258

1262-
fn build_all_auxiliary(&self, of: &TestPaths, aux_dir: &Utf8Path, rustc: &mut Command) {
1259+
fn build_all_auxiliary(&self, aux_dir: &Utf8Path, rustc: &mut Command) {
12631260
for rel_ab in &self.props.aux.builds {
1264-
self.build_auxiliary(of, rel_ab, &aux_dir, None);
1261+
self.build_auxiliary(rel_ab, &aux_dir, None);
12651262
}
12661263

12671264
for rel_ab in &self.props.aux.bins {
1268-
self.build_auxiliary(of, rel_ab, &aux_dir, Some(AuxType::Bin));
1265+
self.build_auxiliary(rel_ab, &aux_dir, Some(AuxType::Bin));
12691266
}
12701267

12711268
let path_to_crate_name = |path: &str| -> String {
@@ -1284,20 +1281,20 @@ impl<'test> TestCx<'test> {
12841281
};
12851282

12861283
for (aux_name, aux_path) in &self.props.aux.crates {
1287-
let aux_type = self.build_auxiliary(of, &aux_path, &aux_dir, None);
1284+
let aux_type = self.build_auxiliary(&aux_path, &aux_dir, None);
12881285
add_extern(rustc, aux_name, aux_path, aux_type);
12891286
}
12901287

12911288
for proc_macro in &self.props.aux.proc_macros {
1292-
self.build_auxiliary(of, proc_macro, &aux_dir, Some(AuxType::ProcMacro));
1289+
self.build_auxiliary(proc_macro, &aux_dir, Some(AuxType::ProcMacro));
12931290
let crate_name = path_to_crate_name(proc_macro);
12941291
add_extern(rustc, &crate_name, proc_macro, AuxType::ProcMacro);
12951292
}
12961293

12971294
// Build any `//@ aux-codegen-backend`, and pass the resulting library
12981295
// to `-Zcodegen-backend` when compiling the test file.
12991296
if let Some(aux_file) = &self.props.aux.codegen_backend {
1300-
let aux_type = self.build_auxiliary(of, aux_file, aux_dir, None);
1297+
let aux_type = self.build_auxiliary(aux_file, aux_dir, None);
13011298
if let Some(lib_name) = get_lib_name(aux_file.trim_end_matches(".rs"), aux_type) {
13021299
let lib_path = aux_dir.join(&lib_name);
13031300
rustc.arg(format!("-Zcodegen-backend={}", lib_path));
@@ -1307,20 +1304,15 @@ impl<'test> TestCx<'test> {
13071304

13081305
/// `root_testpaths` refers to the path of the original test. the auxiliary and the test with an
13091306
/// aux-build have the same `root_testpaths`.
1310-
fn compose_and_run_compiler(
1311-
&self,
1312-
mut rustc: Command,
1313-
input: Option<String>,
1314-
root_testpaths: &TestPaths,
1315-
) -> ProcRes {
1307+
fn compose_and_run_compiler(&self, mut rustc: Command, input: Option<String>) -> ProcRes {
13161308
if self.props.add_core_stubs {
13171309
let minicore_path = self.build_minicore();
13181310
rustc.arg("--extern");
13191311
rustc.arg(&format!("minicore={}", minicore_path));
13201312
}
13211313

13221314
let aux_dir = self.aux_output_dir();
1323-
self.build_all_auxiliary(root_testpaths, &aux_dir, &mut rustc);
1315+
self.build_all_auxiliary(&aux_dir, &mut rustc);
13241316

13251317
rustc.envs(self.props.rustc_env.clone());
13261318
self.props.unset_rustc_env.iter().fold(&mut rustc, Command::env_remove);
@@ -1365,12 +1357,11 @@ impl<'test> TestCx<'test> {
13651357
/// If `aux_type` is `None`, then this will determine the aux-type automatically.
13661358
fn build_auxiliary(
13671359
&self,
1368-
of: &TestPaths,
13691360
source_path: &str,
13701361
aux_dir: &Utf8Path,
13711362
aux_type: Option<AuxType>,
13721363
) -> AuxType {
1373-
let aux_path = self.compute_aux_test_paths(of, source_path);
1364+
let aux_path = self.compute_aux_test_paths(source_path);
13741365
let mut aux_props = self.props.from_aux_file(&aux_path, self.revision, self.config);
13751366
if aux_type == Some(AuxType::ProcMacro) {
13761367
aux_props.force_host = true;
@@ -1401,7 +1392,7 @@ impl<'test> TestCx<'test> {
14011392
LinkToAux::No,
14021393
Vec::new(),
14031394
);
1404-
aux_cx.build_all_auxiliary(of, &aux_dir, &mut aux_rustc);
1395+
aux_cx.build_all_auxiliary(&aux_dir, &mut aux_rustc);
14051396

14061397
aux_rustc.envs(aux_props.rustc_env.clone());
14071398
for key in &aux_props.unset_rustc_env {
@@ -2126,7 +2117,7 @@ impl<'test> TestCx<'test> {
21262117
Vec::new(),
21272118
);
21282119

2129-
let proc_res = self.compose_and_run_compiler(rustc, None, self.testpaths);
2120+
let proc_res = self.compose_and_run_compiler(rustc, None);
21302121
(proc_res, output_path)
21312122
}
21322123

@@ -2204,9 +2195,9 @@ impl<'test> TestCx<'test> {
22042195
Vec::new(),
22052196
);
22062197
let aux_dir = new_rustdoc.aux_output_dir();
2207-
new_rustdoc.build_all_auxiliary(&new_rustdoc.testpaths, &aux_dir, &mut rustc);
2198+
new_rustdoc.build_all_auxiliary(&aux_dir, &mut rustc);
22082199

2209-
let proc_res = new_rustdoc.document(&compare_dir, &new_rustdoc.testpaths, DocKind::Html);
2200+
let proc_res = new_rustdoc.document(&compare_dir, DocKind::Html);
22102201
if !proc_res.status.success() {
22112202
writeln!(self.stderr, "failed to run nightly rustdoc");
22122203
return;

src/tools/compiletest/src/runtest/assembly.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl TestCx<'_> {
4343
Vec::new(),
4444
);
4545

46-
let proc_res = self.compose_and_run_compiler(rustc, None, self.testpaths);
46+
let proc_res = self.compose_and_run_compiler(rustc, None);
4747
(proc_res, output_path)
4848
}
4949
}

src/tools/compiletest/src/runtest/coverage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl<'test> TestCx<'test> {
197197

198198
rustdoc_cmd.arg(&self.testpaths.file);
199199

200-
let proc_res = self.compose_and_run_compiler(rustdoc_cmd, None, self.testpaths);
200+
let proc_res = self.compose_and_run_compiler(rustdoc_cmd, None);
201201
if !proc_res.status.success() {
202202
self.fatal_proc_rec("rustdoc --test failed!", &proc_res)
203203
}

src/tools/compiletest/src/runtest/js_doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ impl TestCx<'_> {
77
if let Some(nodejs) = &self.config.nodejs {
88
let out_dir = self.output_base_dir();
99

10-
self.document(&out_dir, &self.testpaths, DocKind::Html);
10+
self.document(&out_dir, DocKind::Html);
1111

1212
let file_stem = self.testpaths.file.file_stem().expect("no file stem");
1313
let res = self.run_command_to_procres(

src/tools/compiletest/src/runtest/rustdoc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ impl TestCx<'_> {
1111
panic!("failed to remove and recreate output directory `{out_dir}`: {e}")
1212
});
1313

14-
let proc_res = self.document(&out_dir, &self.testpaths, DocKind::Html);
14+
let proc_res = self.document(&out_dir, DocKind::Html);
1515
if !proc_res.status.success() {
1616
self.fatal_proc_rec("rustdoc failed!", &proc_res);
1717
}

src/tools/compiletest/src/runtest/rustdoc_json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ impl TestCx<'_> {
1313
panic!("failed to remove and recreate output directory `{out_dir}`: {e}")
1414
});
1515

16-
let proc_res = self.document(&out_dir, &self.testpaths, DocKind::Json);
16+
let proc_res = self.document(&out_dir, DocKind::Json);
1717
if !proc_res.status.success() {
1818
self.fatal_proc_rec("rustdoc failed!", &proc_res);
1919
}

src/tools/compiletest/src/runtest/ui.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ impl TestCx<'_> {
249249
rustc.arg(crate_name);
250250
}
251251

252-
let res = self.compose_and_run_compiler(rustc, None, self.testpaths);
252+
let res = self.compose_and_run_compiler(rustc, None);
253253
if !res.status.success() {
254254
self.fatal_proc_rec("failed to compile fixed code", &res);
255255
}

0 commit comments

Comments
 (0)