Skip to content

Commit 7939794

Browse files
committed
Remove some parameters that are always self.root_test_paths
1 parent dcb7bd2 commit 7939794

File tree

7 files changed

+36
-42
lines changed

7 files changed

+36
-42
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ impl<'test> TestCx<'test> {
582582
self.maybe_add_external_args(&mut rustc, &self.config.target_rustcflags);
583583
rustc.args(&self.props.compile_flags);
584584

585-
self.compose_and_run_compiler(rustc, Some(src), self.root_test_paths)
585+
self.compose_and_run_compiler(rustc, Some(src))
586586
}
587587

588588
fn maybe_add_external_args(&self, cmd: &mut Command, args: &Vec<String>) {
@@ -1013,22 +1013,17 @@ impl<'test> TestCx<'test> {
10131013
passes,
10141014
);
10151015

1016-
self.compose_and_run_compiler(rustc, None, self.root_test_paths)
1016+
self.compose_and_run_compiler(rustc, None)
10171017
}
10181018

10191019
/// `root_out_dir` and `root_testpaths` refer to the parameters of the actual test being run.
10201020
/// Auxiliaries, no matter how deep, have the same root_out_dir and root_testpaths.
1021-
fn document(
1022-
&self,
1023-
root_out_dir: &Utf8Path,
1024-
root_testpaths: &RootTestPaths,
1025-
kind: DocKind,
1026-
) -> ProcRes {
1021+
fn document(&self, root_out_dir: &Utf8Path, kind: DocKind) -> ProcRes {
10271022
if self.props.build_aux_docs {
10281023
assert_eq!(kind, DocKind::Html, "build-aux-docs only make sense for html output");
10291024

10301025
for rel_ab in &self.props.aux.builds {
1031-
let aux_testpaths = self.compute_aux_test_paths(root_testpaths, rel_ab);
1026+
let aux_testpaths = self.compute_aux_test_paths(rel_ab);
10321027
let props_for_aux =
10331028
self.props.from_aux_file(&aux_testpaths.file, self.revision, self.config);
10341029
let aux_cx = TestCx {
@@ -1044,7 +1039,7 @@ impl<'test> TestCx<'test> {
10441039
create_dir_all(aux_cx.output_base_dir()).unwrap();
10451040
// use root_testpaths here, because aux-builds should have the
10461041
// same --out-dir and auxiliary directory.
1047-
let auxres = aux_cx.document(&root_out_dir, root_testpaths, kind);
1042+
let auxres = aux_cx.document(&root_out_dir, kind);
10481043
if !auxres.status.success() {
10491044
return auxres;
10501045
}
@@ -1072,7 +1067,7 @@ impl<'test> TestCx<'test> {
10721067
};
10731068

10741069
let mut rustdoc = Command::new(rustdoc_path);
1075-
let current_dir = output_base_dir(self.config, root_testpaths, self.safe_revision());
1070+
let current_dir = output_base_dir(self.config, self.root_test_paths, self.safe_revision());
10761071
rustdoc.current_dir(current_dir);
10771072
rustdoc
10781073
.arg("-L")
@@ -1100,7 +1095,7 @@ impl<'test> TestCx<'test> {
11001095
rustdoc.arg(format!("-Clinker={}", linker));
11011096
}
11021097

1103-
self.compose_and_run_compiler(rustdoc, None, root_testpaths)
1098+
self.compose_and_run_compiler(rustdoc, None)
11041099
}
11051100

11061101
fn exec_compiled_test(&self) -> ProcRes {
@@ -1215,16 +1210,22 @@ impl<'test> TestCx<'test> {
12151210

12161211
/// For each `aux-build: foo/bar` annotation, we check to find the file in an `auxiliary`
12171212
/// directory relative to the test itself (not any intermediate auxiliaries).
1218-
fn compute_aux_test_paths(&self, of: &RootTestPaths, rel_ab: &str) -> TestOrAuxPaths {
1219-
let test_ab =
1220-
of.file.parent().expect("test file path has no parent").join("auxiliary").join(rel_ab);
1213+
fn compute_aux_test_paths(&self, rel_ab: &str) -> TestOrAuxPaths {
1214+
let test_ab = self
1215+
.root_test_paths
1216+
.file
1217+
.parent()
1218+
.expect("test file path has no parent")
1219+
.join("auxiliary")
1220+
.join(rel_ab);
12211221
if !test_ab.exists() {
12221222
self.fatal(&format!("aux-build `{}` source not found", test_ab))
12231223
}
12241224

12251225
TestOrAuxPaths {
12261226
file: test_ab,
1227-
relative_dir: of
1227+
relative_dir: self
1228+
.root_test_paths
12281229
.relative_dir
12291230
.join(self.output_testname_unique())
12301231
.join("auxiliary")
@@ -1278,13 +1279,13 @@ impl<'test> TestCx<'test> {
12781279
aux_dir
12791280
}
12801281

1281-
fn build_all_auxiliary(&self, of: &RootTestPaths, aux_dir: &Utf8Path, rustc: &mut Command) {
1282+
fn build_all_auxiliary(&self, aux_dir: &Utf8Path, rustc: &mut Command) {
12821283
for rel_ab in &self.props.aux.builds {
1283-
self.build_auxiliary(of, rel_ab, &aux_dir, None);
1284+
self.build_auxiliary(rel_ab, &aux_dir, None);
12841285
}
12851286

12861287
for rel_ab in &self.props.aux.bins {
1287-
self.build_auxiliary(of, rel_ab, &aux_dir, Some(AuxType::Bin));
1288+
self.build_auxiliary(rel_ab, &aux_dir, Some(AuxType::Bin));
12881289
}
12891290

12901291
let path_to_crate_name = |path: &str| -> String {
@@ -1303,20 +1304,20 @@ impl<'test> TestCx<'test> {
13031304
};
13041305

13051306
for (aux_name, aux_path) in &self.props.aux.crates {
1306-
let aux_type = self.build_auxiliary(of, &aux_path, &aux_dir, None);
1307+
let aux_type = self.build_auxiliary(&aux_path, &aux_dir, None);
13071308
add_extern(rustc, aux_name, aux_path, aux_type);
13081309
}
13091310

13101311
for proc_macro in &self.props.aux.proc_macros {
1311-
self.build_auxiliary(of, proc_macro, &aux_dir, Some(AuxType::ProcMacro));
1312+
self.build_auxiliary(proc_macro, &aux_dir, Some(AuxType::ProcMacro));
13121313
let crate_name = path_to_crate_name(proc_macro);
13131314
add_extern(rustc, &crate_name, proc_macro, AuxType::ProcMacro);
13141315
}
13151316

13161317
// Build any `//@ aux-codegen-backend`, and pass the resulting library
13171318
// to `-Zcodegen-backend` when compiling the test file.
13181319
if let Some(aux_file) = &self.props.aux.codegen_backend {
1319-
let aux_type = self.build_auxiliary(of, aux_file, aux_dir, None);
1320+
let aux_type = self.build_auxiliary(aux_file, aux_dir, None);
13201321
if let Some(lib_name) = get_lib_name(aux_file.trim_end_matches(".rs"), aux_type) {
13211322
let lib_path = aux_dir.join(&lib_name);
13221323
rustc.arg(format!("-Zcodegen-backend={}", lib_path));
@@ -1326,20 +1327,15 @@ impl<'test> TestCx<'test> {
13261327

13271328
/// `root_testpaths` refers to the path of the original test. the auxiliary and the test with an
13281329
/// aux-build have the same `root_testpaths`.
1329-
fn compose_and_run_compiler(
1330-
&self,
1331-
mut rustc: Command,
1332-
input: Option<String>,
1333-
root_testpaths: &RootTestPaths,
1334-
) -> ProcRes {
1330+
fn compose_and_run_compiler(&self, mut rustc: Command, input: Option<String>) -> ProcRes {
13351331
if self.props.add_core_stubs {
13361332
let minicore_path = self.build_minicore();
13371333
rustc.arg("--extern");
13381334
rustc.arg(&format!("minicore={}", minicore_path));
13391335
}
13401336

13411337
let aux_dir = self.aux_output_dir();
1342-
self.build_all_auxiliary(root_testpaths, &aux_dir, &mut rustc);
1338+
self.build_all_auxiliary(&aux_dir, &mut rustc);
13431339

13441340
rustc.envs(self.props.rustc_env.clone());
13451341
self.props.unset_rustc_env.iter().fold(&mut rustc, Command::env_remove);
@@ -1384,12 +1380,11 @@ impl<'test> TestCx<'test> {
13841380
/// If `aux_type` is `None`, then this will determine the aux-type automatically.
13851381
fn build_auxiliary(
13861382
&self,
1387-
of: &RootTestPaths,
13881383
source_path: &str,
13891384
aux_dir: &Utf8Path,
13901385
aux_type: Option<AuxType>,
13911386
) -> AuxType {
1392-
let aux_testpaths = self.compute_aux_test_paths(of, source_path);
1387+
let aux_testpaths = self.compute_aux_test_paths(source_path);
13931388
let mut aux_props =
13941389
self.props.from_aux_file(&aux_testpaths.file, self.revision, self.config);
13951390
if aux_type == Some(AuxType::ProcMacro) {
@@ -1423,7 +1418,7 @@ impl<'test> TestCx<'test> {
14231418
LinkToAux::No,
14241419
Vec::new(),
14251420
);
1426-
aux_cx.build_all_auxiliary(of, &aux_dir, &mut aux_rustc);
1421+
aux_cx.build_all_auxiliary(&aux_dir, &mut aux_rustc);
14271422

14281423
aux_rustc.envs(aux_props.rustc_env.clone());
14291424
for key in &aux_props.unset_rustc_env {
@@ -2153,7 +2148,7 @@ impl<'test> TestCx<'test> {
21532148
Vec::new(),
21542149
);
21552150

2156-
let proc_res = self.compose_and_run_compiler(rustc, None, self.root_test_paths);
2151+
let proc_res = self.compose_and_run_compiler(rustc, None);
21572152
(proc_res, output_path)
21582153
}
21592154

@@ -2231,10 +2226,9 @@ impl<'test> TestCx<'test> {
22312226
Vec::new(),
22322227
);
22332228
let aux_dir = new_rustdoc.aux_output_dir();
2234-
new_rustdoc.build_all_auxiliary(&new_rustdoc.root_test_paths, &aux_dir, &mut rustc);
2229+
new_rustdoc.build_all_auxiliary(&aux_dir, &mut rustc);
22352230

2236-
let proc_res =
2237-
new_rustdoc.document(&compare_dir, &new_rustdoc.root_test_paths, DocKind::Html);
2231+
let proc_res = new_rustdoc.document(&compare_dir, DocKind::Html);
22382232
if !proc_res.status.success() {
22392233
writeln!(self.stderr, "failed to run nightly rustdoc");
22402234
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.root_test_paths);
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.root_test_paths);
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.root_test_paths, 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.root_test_paths, 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.root_test_paths, 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.root_test_paths);
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)