Skip to content

Commit adb71cf

Browse files
committed
working on compiletest, fixing document testpaths bug
1 parent 652b6f8 commit adb71cf

File tree

5 files changed

+35
-44
lines changed

5 files changed

+35
-44
lines changed

src/tools/compiletest/src/command-list.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
99
"aux-codegen-backend",
1010
"aux-crate",
1111
"build-aux-docs",
12+
"unique-doc-aux-dir",
1213
"build-fail",
1314
"build-pass",
1415
"check-fail",
@@ -18,6 +19,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
1819
"check-test-line-numbers-match",
1920
"compare-output-lines-by-subset",
2021
"compile-flags",
22+
"doc-flags",
2123
"dont-check-compiler-stderr",
2224
"dont-check-compiler-stdout",
2325
"dont-check-failure-status",

src/tools/compiletest/src/common.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,6 @@ 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-
194190
/// The coverage-dump executable.
195191
pub coverage_dump_path: Option<PathBuf>,
196192

src/tools/compiletest/src/header.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ pub struct TestProps {
9696
pub compile_flags: Vec<String>,
9797
// Extra flags to pass when the compiled code is run (such as --bench)
9898
pub run_flags: Vec<String>,
99+
/// Extra flags to pass to rustdoc but not the compiler.
100+
pub doc_flags: Vec<String>,
99101
// If present, the name of a file that this test should match when
100102
// pretty-printed
101103
pub pp_exact: Option<PathBuf>,
@@ -123,6 +125,8 @@ pub struct TestProps {
123125
pub unset_exec_env: Vec<String>,
124126
// Build documentation for all specified aux-builds as well
125127
pub build_aux_docs: bool,
128+
// Build the documentation for each crate in a unique output directory
129+
pub unique_doc_aux_dir: bool,
126130
// Flag to force a crate to be built with the host architecture
127131
pub force_host: bool,
128132
// Check stdout for error-pattern output as well as stderr
@@ -221,8 +225,10 @@ mod directives {
221225
pub const REGEX_ERROR_PATTERN: &'static str = "regex-error-pattern";
222226
pub const COMPILE_FLAGS: &'static str = "compile-flags";
223227
pub const RUN_FLAGS: &'static str = "run-flags";
228+
pub const DOC_FLAGS: &'static str = "doc-flags";
224229
pub const SHOULD_ICE: &'static str = "should-ice";
225230
pub const BUILD_AUX_DOCS: &'static str = "build-aux-docs";
231+
pub const UNIQUE_DOC_OUT_DIR: &'static str = "unique-doc-aux-dir";
226232
pub const FORCE_HOST: &'static str = "force-host";
227233
pub const CHECK_STDOUT: &'static str = "check-stdout";
228234
pub const CHECK_RUN_RESULTS: &'static str = "check-run-results";
@@ -268,6 +274,7 @@ impl TestProps {
268274
regex_error_patterns: vec![],
269275
compile_flags: vec![],
270276
run_flags: vec![],
277+
doc_flags: vec![],
271278
pp_exact: None,
272279
aux_builds: vec![],
273280
aux_bins: vec![],
@@ -282,6 +289,7 @@ impl TestProps {
282289
exec_env: vec![],
283290
unset_exec_env: vec![],
284291
build_aux_docs: false,
292+
unique_doc_aux_dir: false,
285293
force_host: false,
286294
check_stdout: false,
287295
check_run_results: false,
@@ -378,6 +386,13 @@ impl TestProps {
378386
|r| r,
379387
);
380388

389+
config.push_name_value_directive(
390+
ln,
391+
DOC_FLAGS,
392+
&mut self.doc_flags,
393+
|r| r,
394+
);
395+
381396
fn split_flags(flags: &str) -> Vec<String> {
382397
// Individual flags can be single-quoted to preserve spaces; see
383398
// <https://github.com/rust-lang/rust/pull/115948/commits/957c5db6>.
@@ -415,6 +430,8 @@ impl TestProps {
415430

416431
config.set_name_directive(ln, SHOULD_ICE, &mut self.should_ice);
417432
config.set_name_directive(ln, BUILD_AUX_DOCS, &mut self.build_aux_docs);
433+
config.set_name_directive(ln, UNIQUE_DOC_OUT_DIR, &mut self.unique_doc_aux_dir);
434+
418435
config.set_name_directive(ln, FORCE_HOST, &mut self.force_host);
419436
config.set_name_directive(ln, CHECK_STDOUT, &mut self.check_stdout);
420437
config.set_name_directive(ln, CHECK_RUN_RESULTS, &mut self.check_run_results);

src/tools/compiletest/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ 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")
8584
.optmulti(
8685
"",
8786
"skip",
@@ -250,7 +249,6 @@ pub fn parse_config(args: Vec<String>) -> Config {
250249
debugger: None,
251250
run_ignored,
252251
with_debug_assertions,
253-
aux_write_doc_cci: matches.opt_present("aux-write-doc-cci"),
254252
filters: matches.free.clone(),
255253
skip: matches.opt_strs("skip"),
256254
filter_exact: matches.opt_present("exact"),

src/tools/compiletest/src/runtest.rs

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,20 +1595,10 @@ impl<'test> TestCx<'test> {
15951595
}
15961596

15971597
/// aux: whether we are building the aux docs or main docs
1598-
fn document(&self, out_dir: &Path, info_json: Option<&Path>) -> ProcRes {
1599-
/// Path to give to --include-info-json and --write-info-json
1600-
fn info_path(cx: &TestCx<'_>, rel_ab: &str) -> PathBuf {
1601-
cx.output_base_dir().parent().unwrap().parent().unwrap()
1602-
.join("doc.parts")
1603-
.join(rel_ab.trim_end_matches(".rs").replace("-", "_"))
1604-
.join("crate-info.json")
1605-
}
1606-
1607-
let mut include_flags = Vec::default();
1608-
1598+
fn document(&self, out_dir: &Path) -> ProcRes {
16091599
if self.props.build_aux_docs {
16101600
for rel_ab in &self.props.aux_builds {
1611-
let aux_testpaths = self.compute_aux_test_paths(&self.testpaths, rel_ab);
1601+
let aux_testpaths = self.compute_aux_test_paths(dbg!(&self.testpaths), dbg!(rel_ab));
16121602
let aux_props =
16131603
self.props.from_aux_file(&aux_testpaths.file, self.revision, self.config);
16141604
let aux_cx = TestCx {
@@ -1617,11 +1607,14 @@ impl<'test> TestCx<'test> {
16171607
testpaths: &aux_testpaths,
16181608
revision: self.revision,
16191609
};
1620-
let info_json = info_path(&aux_cx, rel_ab);
1621-
include_flags.push(format!("--include-info-json={}", info_json.display()));
16221610
// Create the directory for the stdout/stderr files.
16231611
create_dir_all(aux_cx.output_base_dir()).unwrap();
1624-
let auxres = aux_cx.document(out_dir, Some(&info_json));
1612+
let out_dir = if aux_props.unique_doc_aux_dir {
1613+
out_dir.join("docs").join(rel_ab.trim_end_matches(".rs")).join("doc")
1614+
} else {
1615+
out_dir.to_owned()
1616+
};
1617+
let auxres = aux_cx.document(&out_dir);
16251618
if !auxres.status.success() {
16261619
return auxres;
16271620
}
@@ -1645,24 +1638,8 @@ impl<'test> TestCx<'test> {
16451638
.arg(&self.testpaths.file)
16461639
.arg("-A")
16471640
.arg("internal_features")
1648-
.args(&self.props.compile_flags);
1649-
1650-
if self.config.aux_write_doc_cci {
1651-
match info_json {
1652-
Some(info_json) => {
1653-
rustdoc
1654-
.arg("-Zunstable-options")
1655-
.arg("--merge=none")
1656-
.arg(format!("--write-info-json={}", info_json.display()));
1657-
}
1658-
None => {
1659-
rustdoc
1660-
.arg("-Zunstable-options")
1661-
.arg("--merge=write-only")
1662-
.args(&include_flags);
1663-
}
1664-
}
1665-
}
1641+
.args(&self.props.compile_flags)
1642+
.args(&self.props.doc_flags);
16661643

16671644
if self.config.mode == RustdocJson {
16681645
rustdoc.arg("--output-format").arg("json").arg("-Zunstable-options");
@@ -1788,6 +1765,7 @@ impl<'test> TestCx<'test> {
17881765
fn compute_aux_test_paths(&self, of: &TestPaths, rel_ab: &str) -> TestPaths {
17891766
let test_ab =
17901767
of.file.parent().expect("test file path has no parent").join("auxiliary").join(rel_ab);
1768+
dbg!(&of, rel_ab, &test_ab);
17911769
if !test_ab.exists() {
17921770
self.fatal(&format!("aux-build `{}` source not found", test_ab.display()))
17931771
}
@@ -1892,7 +1870,7 @@ impl<'test> TestCx<'test> {
18921870
aux_dir: &Path,
18931871
is_bin: bool,
18941872
) -> AuxType {
1895-
let aux_testpaths = self.compute_aux_test_paths(of, source_path);
1873+
let aux_testpaths = self.compute_aux_test_paths(dbg!(of), dbg!(source_path));
18961874
let aux_props = self.props.from_aux_file(&aux_testpaths.file, self.revision, self.config);
18971875
let mut aux_dir = aux_dir.to_path_buf();
18981876
if is_bin {
@@ -2706,7 +2684,7 @@ impl<'test> TestCx<'test> {
27062684
let out_dir = self.output_base_dir();
27072685
remove_and_create_dir_all(&out_dir);
27082686

2709-
let proc_res = self.document(&out_dir, None);
2687+
let proc_res = self.document(&out_dir);
27102688
if !proc_res.status.success() {
27112689
self.fatal_proc_rec("rustdoc failed!", &proc_res);
27122690
}
@@ -2765,7 +2743,7 @@ impl<'test> TestCx<'test> {
27652743
let aux_dir = new_rustdoc.aux_output_dir();
27662744
new_rustdoc.build_all_auxiliary(&new_rustdoc.testpaths, &aux_dir, &mut rustc);
27672745

2768-
let proc_res = new_rustdoc.document(&compare_dir, None);
2746+
let proc_res = new_rustdoc.document(&compare_dir);
27692747
if !proc_res.status.success() {
27702748
eprintln!("failed to run nightly rustdoc");
27712749
return;
@@ -2888,7 +2866,7 @@ impl<'test> TestCx<'test> {
28882866
let out_dir = self.output_base_dir();
28892867
remove_and_create_dir_all(&out_dir);
28902868

2891-
let proc_res = self.document(&out_dir, None);
2869+
let proc_res = self.document(&out_dir);
28922870
if !proc_res.status.success() {
28932871
self.fatal_proc_rec("rustdoc failed!", &proc_res);
28942872
}
@@ -3818,7 +3796,7 @@ impl<'test> TestCx<'test> {
38183796
if let Some(nodejs) = &self.config.nodejs {
38193797
let out_dir = self.output_base_dir();
38203798

3821-
self.document(&out_dir, None);
3799+
self.document(&out_dir);
38223800

38233801
let root = self.config.find_rust_src_root().unwrap();
38243802
let file_stem =

0 commit comments

Comments
 (0)