Skip to content

Commit 0b636cc

Browse files
committed
hacked compiletest
1 parent c562d17 commit 0b636cc

File tree

3 files changed

+43
-7
lines changed

3 files changed

+43
-7
lines changed

src/tools/compiletest/src/common.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ pub struct Config {
187187
/// The rustdoc executable.
188188
pub rustdoc_path: Option<PathBuf>,
189189

190+
/// for rustdoc: whether to write intermediate cross-crate information to crate root
191+
/// for auxiliary crates
192+
pub aux_write_doc_cci: bool,
193+
190194
/// The coverage-dump executable.
191195
pub coverage_dump_path: Option<PathBuf>,
192196

src/tools/compiletest/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
8181
.optopt("", "run", "whether to execute run-* tests", "auto | always | never")
8282
.optflag("", "ignored", "run tests marked as ignored")
8383
.optflag("", "with-debug-assertions", "whether to run tests with `ignore-debug` header")
84+
.optflag("", "aux-write-doc-cci", "whether to write cci for auxiliary crates")
8485
.optmulti(
8586
"",
8687
"skip",
@@ -249,6 +250,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
249250
debugger: None,
250251
run_ignored,
251252
with_debug_assertions,
253+
aux_write_doc_cci: matches.opt_present("aux-write-doc-cci"),
252254
filters: matches.free.clone(),
253255
skip: matches.opt_strs("skip"),
254256
filter_exact: matches.opt_present("exact"),

src/tools/compiletest/src/runtest.rs

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,18 @@ impl<'test> TestCx<'test> {
15911591
self.compose_and_run_compiler(rustc, None)
15921592
}
15931593

1594-
fn document(&self, out_dir: &Path) -> ProcRes {
1594+
/// aux: whether we are building the aux docs or main docs
1595+
fn document(&self, out_dir: &Path, info_json: Option<&Path>) -> ProcRes {
1596+
/// Path to give to --include-info-json and --write-info-json
1597+
fn info_path(cx: &TestCx<'_>, rel_ab: &str) -> PathBuf {
1598+
cx.output_base_dir().parent().unwrap().parent().unwrap()
1599+
.join("doc.parts")
1600+
.join(rel_ab.trim_end_matches(".rs").replace("-", "_"))
1601+
.join("crate-info.json")
1602+
}
1603+
1604+
let mut include_flags = Vec::default();
1605+
15951606
if self.props.build_aux_docs {
15961607
for rel_ab in &self.props.aux_builds {
15971608
let aux_testpaths = self.compute_aux_test_paths(&self.testpaths, rel_ab);
@@ -1603,9 +1614,11 @@ impl<'test> TestCx<'test> {
16031614
testpaths: &aux_testpaths,
16041615
revision: self.revision,
16051616
};
1617+
let info_json = info_path(&aux_cx, rel_ab);
1618+
include_flags.push(format!("--include-info-json={}", info_json.display()));
16061619
// Create the directory for the stdout/stderr files.
16071620
create_dir_all(aux_cx.output_base_dir()).unwrap();
1608-
let auxres = aux_cx.document(out_dir);
1621+
let auxres = aux_cx.document(out_dir, Some(&info_json));
16091622
if !auxres.status.success() {
16101623
return auxres;
16111624
}
@@ -1615,8 +1628,8 @@ impl<'test> TestCx<'test> {
16151628
let aux_dir = self.aux_output_dir_name();
16161629

16171630
let rustdoc_path = self.config.rustdoc_path.as_ref().expect("--rustdoc-path not passed");
1618-
let mut rustdoc = Command::new(rustdoc_path);
16191631

1632+
let mut rustdoc = Command::new(rustdoc_path);
16201633
rustdoc
16211634
.arg("-L")
16221635
.arg(self.config.run_lib_path.to_str().unwrap())
@@ -1631,6 +1644,23 @@ impl<'test> TestCx<'test> {
16311644
.arg("internal_features")
16321645
.args(&self.props.compile_flags);
16331646

1647+
if self.config.aux_write_doc_cci {
1648+
match info_json {
1649+
Some(info_json) => {
1650+
rustdoc
1651+
.arg("-Zunstable-options")
1652+
.arg("--merge=none")
1653+
.arg(format!("--write-info-json={}", info_json.display()));
1654+
}
1655+
None => {
1656+
rustdoc
1657+
.arg("-Zunstable-options")
1658+
.arg("--merge=write-only")
1659+
.args(&include_flags);
1660+
}
1661+
}
1662+
}
1663+
16341664
if self.config.mode == RustdocJson {
16351665
rustdoc.arg("--output-format").arg("json").arg("-Zunstable-options");
16361666
}
@@ -2673,7 +2703,7 @@ impl<'test> TestCx<'test> {
26732703
let out_dir = self.output_base_dir();
26742704
remove_and_create_dir_all(&out_dir);
26752705

2676-
let proc_res = self.document(&out_dir);
2706+
let proc_res = self.document(&out_dir, None);
26772707
if !proc_res.status.success() {
26782708
self.fatal_proc_rec("rustdoc failed!", &proc_res);
26792709
}
@@ -2732,7 +2762,7 @@ impl<'test> TestCx<'test> {
27322762
let aux_dir = new_rustdoc.aux_output_dir();
27332763
new_rustdoc.build_all_auxiliary(&new_rustdoc.testpaths, &aux_dir, &mut rustc);
27342764

2735-
let proc_res = new_rustdoc.document(&compare_dir);
2765+
let proc_res = new_rustdoc.document(&compare_dir, None);
27362766
if !proc_res.status.success() {
27372767
eprintln!("failed to run nightly rustdoc");
27382768
return;
@@ -2855,7 +2885,7 @@ impl<'test> TestCx<'test> {
28552885
let out_dir = self.output_base_dir();
28562886
remove_and_create_dir_all(&out_dir);
28572887

2858-
let proc_res = self.document(&out_dir);
2888+
let proc_res = self.document(&out_dir, None);
28592889
if !proc_res.status.success() {
28602890
self.fatal_proc_rec("rustdoc failed!", &proc_res);
28612891
}
@@ -3697,7 +3727,7 @@ impl<'test> TestCx<'test> {
36973727
if let Some(nodejs) = &self.config.nodejs {
36983728
let out_dir = self.output_base_dir();
36993729

3700-
self.document(&out_dir);
3730+
self.document(&out_dir, None);
37013731

37023732
let root = self.config.find_rust_src_root().unwrap();
37033733
let file_stem =

0 commit comments

Comments
 (0)