Skip to content

Commit 08837d2

Browse files
committed
pass revision and incr_comp directory to auxbuild
This is needed for incremental compilation harness to support cross-crate testing. Also support cfg for typechecking prettyprint
1 parent 8f3a8c2 commit 08837d2

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

src/tools/compiletest/src/header.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ pub struct TestProps {
162162
pub forbid_output: Vec<String>,
163163
// Revisions to test for incremental compilation.
164164
pub revisions: Vec<String>,
165+
// Directory (if any) to use for incremental compilation. This is
166+
// not set by end-users; rather it is set by the incremental
167+
// testing harness and used when generating compilation
168+
// arguments. (In particular, it propagates to the aux-builds.)
169+
pub incremental_dir: Option<PathBuf>,
165170
}
166171

167172
impl TestProps {
@@ -197,9 +202,20 @@ impl TestProps {
197202
pretty_mode: format!("normal"),
198203
pretty_compare_only: pretty_compare_only,
199204
forbid_output: forbid_output,
205+
incremental_dir: None,
200206
}
201207
}
202208

209+
pub fn from_aux_file(&self, testfile: &Path, cfg: Option<&str>) -> Self {
210+
let mut props = TestProps::new();
211+
212+
// copy over select properties to the aux build:
213+
props.incremental_dir = self.incremental_dir.clone();
214+
props.load_from(testfile, cfg);
215+
216+
props
217+
}
218+
203219
pub fn from_file(testfile: &Path) -> Self {
204220
let mut props = TestProps::new();
205221
props.load_from(testfile, None);

src/tools/compiletest/src/runtest.rs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ pub fn run(config: Config, testpaths: &TestPaths) {
6363
for revision in &base_props.revisions {
6464
let mut revision_props = base_props.clone();
6565
revision_props.load_from(&testpaths.file, Some(&revision));
66-
revision_props.compile_flags.extend(vec![
67-
format!("--cfg"),
68-
format!("{}", revision),
69-
]);
7066
let rev_cx = TestCx {
7167
config: &config,
7268
props: &revision_props,
@@ -383,6 +379,12 @@ actual:\n\
383379
self.config.build_base.to_str().unwrap().to_owned(),
384380
"-L".to_owned(),
385381
aux_dir.to_str().unwrap().to_owned());
382+
if let Some(revision) = self.revision {
383+
args.extend(vec![
384+
format!("--cfg"),
385+
format!("{}", revision),
386+
]);
387+
}
386388
args.extend(self.split_maybe_args(&self.config.target_rustcflags));
387389
args.extend(self.props.compile_flags.iter().cloned());
388390
// FIXME (#9639): This needs to handle non-utf8 paths
@@ -1102,7 +1104,7 @@ actual:\n\
11021104
if self.props.build_aux_docs {
11031105
for rel_ab in &self.props.aux_builds {
11041106
let aux_testpaths = self.compute_aux_test_paths(rel_ab);
1105-
let aux_props = TestProps::from_file(&aux_testpaths.file);
1107+
let aux_props = self.props.from_aux_file(&aux_testpaths.file, self.revision);
11061108
let aux_cx = TestCx {
11071109
config: self.config,
11081110
props: &aux_props,
@@ -1186,7 +1188,7 @@ actual:\n\
11861188

11871189
for rel_ab in &self.props.aux_builds {
11881190
let aux_testpaths = self.compute_aux_test_paths(rel_ab);
1189-
let aux_props = TestProps::from_file(&aux_testpaths.file);
1191+
let aux_props = self.props.from_aux_file(&aux_testpaths.file, self.revision);
11901192
let mut crate_type = if aux_props.no_prefer_dynamic {
11911193
Vec::new()
11921194
} else {
@@ -1291,6 +1293,21 @@ actual:\n\
12911293
self.config.build_base.to_str().unwrap().to_owned(),
12921294
format!("--target={}", target));
12931295

1296+
if let Some(revision) = self.revision {
1297+
args.extend(vec![
1298+
format!("--cfg"),
1299+
format!("{}", revision),
1300+
]);
1301+
}
1302+
1303+
if let Some(ref incremental_dir) = self.props.incremental_dir {
1304+
args.extend(vec![
1305+
format!("-Z"),
1306+
format!("incremental={}", incremental_dir.display()),
1307+
]);
1308+
}
1309+
1310+
12941311
match self.config.mode {
12951312
CompileFail |
12961313
ParseFail |
@@ -1980,10 +1997,7 @@ actual:\n\
19801997

19811998
// Add an extra flag pointing at the incremental directory.
19821999
let mut revision_props = self.props.clone();
1983-
revision_props.compile_flags.extend(vec![
1984-
format!("-Z"),
1985-
format!("incremental={}", incremental_dir.display()),
1986-
]);
2000+
revision_props.incremental_dir = Some(incremental_dir);
19872001

19882002
let revision_cx = TestCx {
19892003
config: self.config,

0 commit comments

Comments
 (0)