Skip to content

Commit a0d516a

Browse files
committed
Remove some parameters that are always self.testpaths
1 parent 379f3a5 commit a0d516a

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,32 +993,26 @@ 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
fn document_inner(
10111006
&self,
10121007
file_to_doc: &Utf8Path,
10131008
root_out_dir: &Utf8Path,
1014-
root_testpaths: &TestPaths,
10151009
kind: DocKind,
10161010
) -> ProcRes {
10171011
if self.props.build_aux_docs {
10181012
assert_eq!(kind, DocKind::Html, "build-aux-docs only make sense for html output");
10191013

10201014
for rel_ab in &self.props.aux.builds {
1021-
let aux_path = self.compute_aux_test_paths(root_testpaths, rel_ab);
1015+
let aux_path = self.compute_aux_test_paths(rel_ab);
10221016
let props_for_aux = self.props.from_aux_file(&aux_path, self.revision, self.config);
10231017
let aux_cx = TestCx {
10241018
config: self.config,
@@ -1030,9 +1024,7 @@ impl<'test> TestCx<'test> {
10301024
};
10311025
// Create the directory for the stdout/stderr files.
10321026
create_dir_all(aux_cx.output_base_dir()).unwrap();
1033-
// use root_testpaths here, because aux-builds should have the
1034-
// same --out-dir and auxiliary directory.
1035-
let auxres = aux_cx.document_inner(&aux_path, &root_out_dir, root_testpaths, kind);
1027+
let auxres = aux_cx.document_inner(&aux_path, &root_out_dir, kind);
10361028
if !auxres.status.success() {
10371029
return auxres;
10381030
}
@@ -1060,7 +1052,7 @@ impl<'test> TestCx<'test> {
10601052
};
10611053

10621054
let mut rustdoc = Command::new(rustdoc_path);
1063-
let current_dir = output_base_dir(self.config, root_testpaths, self.safe_revision());
1055+
let current_dir = self.output_base_dir();
10641056
rustdoc.current_dir(current_dir);
10651057
rustdoc
10661058
.arg("-L")
@@ -1088,7 +1080,7 @@ impl<'test> TestCx<'test> {
10881080
rustdoc.arg(format!("-Clinker={}", linker));
10891081
}
10901082

1091-
self.compose_and_run_compiler(rustdoc, None, root_testpaths)
1083+
self.compose_and_run_compiler(rustdoc, None)
10921084
}
10931085

10941086
fn exec_compiled_test(&self) -> ProcRes {
@@ -1203,9 +1195,14 @@ impl<'test> TestCx<'test> {
12031195

12041196
/// For each `aux-build: foo/bar` annotation, we check to find the file in an `auxiliary`
12051197
/// directory relative to the test itself (not any intermediate auxiliaries).
1206-
fn compute_aux_test_paths(&self, of: &TestPaths, rel_ab: &str) -> Utf8PathBuf {
1207-
let test_ab =
1208-
of.file.parent().expect("test file path has no parent").join("auxiliary").join(rel_ab);
1198+
fn compute_aux_test_paths(&self, rel_ab: &str) -> Utf8PathBuf {
1199+
let test_ab = self
1200+
.testpaths
1201+
.file
1202+
.parent()
1203+
.expect("test file path has no parent")
1204+
.join("auxiliary")
1205+
.join(rel_ab);
12091206
if !test_ab.exists() {
12101207
self.fatal(&format!("aux-build `{}` source not found", test_ab))
12111208
}
@@ -1256,13 +1253,13 @@ impl<'test> TestCx<'test> {
12561253
aux_dir
12571254
}
12581255

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

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

12681265
let path_to_crate_name = |path: &str| -> String {
@@ -1281,20 +1278,20 @@ impl<'test> TestCx<'test> {
12811278
};
12821279

12831280
for (aux_name, aux_path) in &self.props.aux.crates {
1284-
let aux_type = self.build_auxiliary(of, &aux_path, &aux_dir, None);
1281+
let aux_type = self.build_auxiliary(&aux_path, &aux_dir, None);
12851282
add_extern(rustc, aux_name, aux_path, aux_type);
12861283
}
12871284

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

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

13051302
/// `root_testpaths` refers to the path of the original test. the auxiliary and the test with an
13061303
/// aux-build have the same `root_testpaths`.
1307-
fn compose_and_run_compiler(
1308-
&self,
1309-
mut rustc: Command,
1310-
input: Option<String>,
1311-
root_testpaths: &TestPaths,
1312-
) -> ProcRes {
1304+
fn compose_and_run_compiler(&self, mut rustc: Command, input: Option<String>) -> ProcRes {
13131305
if self.props.add_core_stubs {
13141306
let minicore_path = self.build_minicore();
13151307
rustc.arg("--extern");
13161308
rustc.arg(&format!("minicore={}", minicore_path));
13171309
}
13181310

13191311
let aux_dir = self.aux_output_dir();
1320-
self.build_all_auxiliary(root_testpaths, &aux_dir, &mut rustc);
1312+
self.build_all_auxiliary(&aux_dir, &mut rustc);
13211313

13221314
rustc.envs(self.props.rustc_env.clone());
13231315
self.props.unset_rustc_env.iter().fold(&mut rustc, Command::env_remove);
@@ -1362,12 +1354,11 @@ impl<'test> TestCx<'test> {
13621354
/// If `aux_type` is `None`, then this will determine the aux-type automatically.
13631355
fn build_auxiliary(
13641356
&self,
1365-
of: &TestPaths,
13661357
source_path: &str,
13671358
aux_dir: &Utf8Path,
13681359
aux_type: Option<AuxType>,
13691360
) -> AuxType {
1370-
let aux_path = self.compute_aux_test_paths(of, source_path);
1361+
let aux_path = self.compute_aux_test_paths(source_path);
13711362
let mut aux_props = self.props.from_aux_file(&aux_path, self.revision, self.config);
13721363
if aux_type == Some(AuxType::ProcMacro) {
13731364
aux_props.force_host = true;
@@ -1398,7 +1389,7 @@ impl<'test> TestCx<'test> {
13981389
LinkToAux::No,
13991390
Vec::new(),
14001391
);
1401-
aux_cx.build_all_auxiliary(of, &aux_dir, &mut aux_rustc);
1392+
aux_cx.build_all_auxiliary(&aux_dir, &mut aux_rustc);
14021393

14031394
aux_rustc.envs(aux_props.rustc_env.clone());
14041395
for key in &aux_props.unset_rustc_env {
@@ -2123,7 +2114,7 @@ impl<'test> TestCx<'test> {
21232114
Vec::new(),
21242115
);
21252116

2126-
let proc_res = self.compose_and_run_compiler(rustc, None, self.testpaths);
2117+
let proc_res = self.compose_and_run_compiler(rustc, None);
21272118
(proc_res, output_path)
21282119
}
21292120

@@ -2201,9 +2192,9 @@ impl<'test> TestCx<'test> {
22012192
Vec::new(),
22022193
);
22032194
let aux_dir = new_rustdoc.aux_output_dir();
2204-
new_rustdoc.build_all_auxiliary(&new_rustdoc.testpaths, &aux_dir, &mut rustc);
2195+
new_rustdoc.build_all_auxiliary(&aux_dir, &mut rustc);
22052196

2206-
let proc_res = new_rustdoc.document(&compare_dir, &new_rustdoc.testpaths, DocKind::Html);
2197+
let proc_res = new_rustdoc.document(&compare_dir, DocKind::Html);
22072198
if !proc_res.status.success() {
22082199
writeln!(self.stderr, "failed to run nightly rustdoc");
22092200
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)