Skip to content

Commit 379f3a5

Browse files
committed
Don't modify testpaths when creating aux contexts
1 parent 21143a2 commit 379f3a5

File tree

1 file changed

+23
-32
lines changed

1 file changed

+23
-32
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use crate::common::{
1818
CompareMode, Config, Debugger, FailMode, PassMode, RunFailMode, RunResult, TestMode, TestPaths,
1919
TestSuite, UI_EXTENSIONS, UI_FIXED, UI_RUN_STDERR, UI_RUN_STDOUT, UI_STDERR, UI_STDOUT, UI_SVG,
2020
UI_WINDOWS_SVG, expected_output_path, incremental_dir, output_base_dir, output_base_name,
21-
output_testname_unique,
2221
};
2322
use crate::directives::TestProps;
2423
use crate::errors::{Error, ErrorKind, load_errors};
@@ -1004,27 +1003,36 @@ impl<'test> TestCx<'test> {
10041003
root_out_dir: &Utf8Path,
10051004
root_testpaths: &TestPaths,
10061005
kind: DocKind,
1006+
) -> ProcRes {
1007+
self.document_inner(&self.testpaths.file, root_out_dir, root_testpaths, kind)
1008+
}
1009+
1010+
fn document_inner(
1011+
&self,
1012+
file_to_doc: &Utf8Path,
1013+
root_out_dir: &Utf8Path,
1014+
root_testpaths: &TestPaths,
1015+
kind: DocKind,
10071016
) -> ProcRes {
10081017
if self.props.build_aux_docs {
10091018
assert_eq!(kind, DocKind::Html, "build-aux-docs only make sense for html output");
10101019

10111020
for rel_ab in &self.props.aux.builds {
1012-
let aux_testpaths = self.compute_aux_test_paths(root_testpaths, rel_ab);
1013-
let props_for_aux =
1014-
self.props.from_aux_file(&aux_testpaths.file, self.revision, self.config);
1021+
let aux_path = self.compute_aux_test_paths(root_testpaths, rel_ab);
1022+
let props_for_aux = self.props.from_aux_file(&aux_path, self.revision, self.config);
10151023
let aux_cx = TestCx {
10161024
config: self.config,
10171025
stdout: self.stdout,
10181026
stderr: self.stderr,
10191027
props: &props_for_aux,
1020-
testpaths: &aux_testpaths,
1028+
testpaths: self.testpaths,
10211029
revision: self.revision,
10221030
};
10231031
// Create the directory for the stdout/stderr files.
10241032
create_dir_all(aux_cx.output_base_dir()).unwrap();
10251033
// use root_testpaths here, because aux-builds should have the
10261034
// same --out-dir and auxiliary directory.
1027-
let auxres = aux_cx.document(&root_out_dir, root_testpaths, kind);
1035+
let auxres = aux_cx.document_inner(&aux_path, &root_out_dir, root_testpaths, kind);
10281036
if !auxres.status.success() {
10291037
return auxres;
10301038
}
@@ -1038,7 +1046,7 @@ impl<'test> TestCx<'test> {
10381046
// actual --out-dir given to the auxiliary or test, as opposed to the root out dir for the entire
10391047
// test
10401048
let out_dir: Cow<'_, Utf8Path> = if self.props.unique_doc_out_dir {
1041-
let file_name = self.testpaths.file.file_stem().expect("file name should not be empty");
1049+
let file_name = file_to_doc.file_stem().expect("file name should not be empty");
10421050
let out_dir = Utf8PathBuf::from_iter([
10431051
root_out_dir,
10441052
Utf8Path::new("docs"),
@@ -1063,7 +1071,7 @@ impl<'test> TestCx<'test> {
10631071
.arg(out_dir.as_ref())
10641072
.arg("--deny")
10651073
.arg("warnings")
1066-
.arg(&self.testpaths.file)
1074+
.arg(file_to_doc)
10671075
.arg("-A")
10681076
.arg("internal_features")
10691077
.args(&self.props.compile_flags)
@@ -1195,24 +1203,14 @@ impl<'test> TestCx<'test> {
11951203

11961204
/// For each `aux-build: foo/bar` annotation, we check to find the file in an `auxiliary`
11971205
/// directory relative to the test itself (not any intermediate auxiliaries).
1198-
fn compute_aux_test_paths(&self, of: &TestPaths, rel_ab: &str) -> TestPaths {
1206+
fn compute_aux_test_paths(&self, of: &TestPaths, rel_ab: &str) -> Utf8PathBuf {
11991207
let test_ab =
12001208
of.file.parent().expect("test file path has no parent").join("auxiliary").join(rel_ab);
12011209
if !test_ab.exists() {
12021210
self.fatal(&format!("aux-build `{}` source not found", test_ab))
12031211
}
12041212

1205-
TestPaths {
1206-
file: test_ab,
1207-
relative_dir: of
1208-
.relative_dir
1209-
.join(self.output_testname_unique())
1210-
.join("auxiliary")
1211-
.join(rel_ab)
1212-
.parent()
1213-
.expect("aux-build path has no parent")
1214-
.to_path_buf(),
1215-
}
1213+
test_ab
12161214
}
12171215

12181216
fn is_vxworks_pure_static(&self) -> bool {
@@ -1369,9 +1367,8 @@ impl<'test> TestCx<'test> {
13691367
aux_dir: &Utf8Path,
13701368
aux_type: Option<AuxType>,
13711369
) -> AuxType {
1372-
let aux_testpaths = self.compute_aux_test_paths(of, source_path);
1373-
let mut aux_props =
1374-
self.props.from_aux_file(&aux_testpaths.file, self.revision, self.config);
1370+
let aux_path = self.compute_aux_test_paths(of, source_path);
1371+
let mut aux_props = self.props.from_aux_file(&aux_path, self.revision, self.config);
13751372
if aux_type == Some(AuxType::ProcMacro) {
13761373
aux_props.force_host = true;
13771374
}
@@ -1388,14 +1385,13 @@ impl<'test> TestCx<'test> {
13881385
stdout: self.stdout,
13891386
stderr: self.stderr,
13901387
props: &aux_props,
1391-
testpaths: &aux_testpaths,
1388+
testpaths: self.testpaths,
13921389
revision: self.revision,
13931390
};
13941391
// Create the directory for the stdout/stderr files.
13951392
create_dir_all(aux_cx.output_base_dir()).unwrap();
1396-
let input_file = &aux_testpaths.file;
13971393
let mut aux_rustc = aux_cx.make_compile_args(
1398-
input_file,
1394+
&aux_path,
13991395
aux_output,
14001396
Emit::None,
14011397
AllowUnused::No,
@@ -1471,7 +1467,7 @@ impl<'test> TestCx<'test> {
14711467
);
14721468
if !auxres.status.success() {
14731469
self.fatal_proc_rec(
1474-
&format!("auxiliary build of {} failed to compile: ", aux_testpaths.file),
1470+
&format!("auxiliary build of {aux_path} failed to compile: "),
14751471
&auxres,
14761472
);
14771473
}
@@ -2033,11 +2029,6 @@ impl<'test> TestCx<'test> {
20332029
self.aux_output_dir_name().join("bin")
20342030
}
20352031

2036-
/// Generates a unique name for the test, such as `testname.revision.mode`.
2037-
fn output_testname_unique(&self) -> Utf8PathBuf {
2038-
output_testname_unique(self.config, self.testpaths, self.safe_revision())
2039-
}
2040-
20412032
/// The revision, ignored for incremental compilation since it wants all revisions in
20422033
/// the same directory.
20432034
fn safe_revision(&self) -> Option<&str> {

0 commit comments

Comments
 (0)