compiletest: pass rustdoc mode as param, rather than implicitly
Spun out of https://www.github.com/rust-lang/rust/pull/142642 In the future, I want the rustdoc-json test suite to invoke rustdoc twice, once with `--output-format=json`, and once with the (not yet implemented) `--output-format=postcard` flag. Doing that requires being able to explicitly tell the `.document()` function which format to use, rather then implicitly using json in the rustdoc-json suite, and HTML in all others.
This commit is contained in:
@@ -1000,8 +1000,15 @@ impl<'test> TestCx<'test> {
|
|||||||
|
|
||||||
/// `root_out_dir` and `root_testpaths` refer to the parameters of the actual test being run.
|
/// `root_out_dir` and `root_testpaths` refer to the parameters of the actual test being run.
|
||||||
/// Auxiliaries, no matter how deep, have the same root_out_dir and root_testpaths.
|
/// Auxiliaries, no matter how deep, have the same root_out_dir and root_testpaths.
|
||||||
fn document(&self, root_out_dir: &Utf8Path, root_testpaths: &TestPaths) -> ProcRes {
|
fn document(
|
||||||
|
&self,
|
||||||
|
root_out_dir: &Utf8Path,
|
||||||
|
root_testpaths: &TestPaths,
|
||||||
|
kind: DocKind,
|
||||||
|
) -> ProcRes {
|
||||||
if self.props.build_aux_docs {
|
if self.props.build_aux_docs {
|
||||||
|
assert_eq!(kind, DocKind::Html, "build-aux-docs only make sense for html output");
|
||||||
|
|
||||||
for rel_ab in &self.props.aux.builds {
|
for rel_ab in &self.props.aux.builds {
|
||||||
let aux_testpaths = self.compute_aux_test_paths(root_testpaths, rel_ab);
|
let aux_testpaths = self.compute_aux_test_paths(root_testpaths, rel_ab);
|
||||||
let props_for_aux =
|
let props_for_aux =
|
||||||
@@ -1018,7 +1025,7 @@ impl<'test> TestCx<'test> {
|
|||||||
create_dir_all(aux_cx.output_base_dir()).unwrap();
|
create_dir_all(aux_cx.output_base_dir()).unwrap();
|
||||||
// use root_testpaths here, because aux-builds should have the
|
// use root_testpaths here, because aux-builds should have the
|
||||||
// same --out-dir and auxiliary directory.
|
// same --out-dir and auxiliary directory.
|
||||||
let auxres = aux_cx.document(&root_out_dir, root_testpaths);
|
let auxres = aux_cx.document(&root_out_dir, root_testpaths, kind);
|
||||||
if !auxres.status.success() {
|
if !auxres.status.success() {
|
||||||
return auxres;
|
return auxres;
|
||||||
}
|
}
|
||||||
@@ -1063,9 +1070,12 @@ impl<'test> TestCx<'test> {
|
|||||||
.args(&self.props.compile_flags)
|
.args(&self.props.compile_flags)
|
||||||
.args(&self.props.doc_flags);
|
.args(&self.props.doc_flags);
|
||||||
|
|
||||||
if self.config.mode == TestMode::RustdocJson {
|
match kind {
|
||||||
|
DocKind::Html => {}
|
||||||
|
DocKind::Json => {
|
||||||
rustdoc.arg("--output-format").arg("json").arg("-Zunstable-options");
|
rustdoc.arg("--output-format").arg("json").arg("-Zunstable-options");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(ref linker) = self.config.target_linker {
|
if let Some(ref linker) = self.config.target_linker {
|
||||||
rustdoc.arg(format!("-Clinker={}", linker));
|
rustdoc.arg(format!("-Clinker={}", linker));
|
||||||
@@ -2203,7 +2213,7 @@ impl<'test> TestCx<'test> {
|
|||||||
let aux_dir = new_rustdoc.aux_output_dir();
|
let aux_dir = new_rustdoc.aux_output_dir();
|
||||||
new_rustdoc.build_all_auxiliary(&new_rustdoc.testpaths, &aux_dir, &mut rustc);
|
new_rustdoc.build_all_auxiliary(&new_rustdoc.testpaths, &aux_dir, &mut rustc);
|
||||||
|
|
||||||
let proc_res = new_rustdoc.document(&compare_dir, &new_rustdoc.testpaths);
|
let proc_res = new_rustdoc.document(&compare_dir, &new_rustdoc.testpaths, DocKind::Html);
|
||||||
if !proc_res.status.success() {
|
if !proc_res.status.success() {
|
||||||
writeln!(self.stderr, "failed to run nightly rustdoc");
|
writeln!(self.stderr, "failed to run nightly rustdoc");
|
||||||
return;
|
return;
|
||||||
@@ -3121,6 +3131,12 @@ enum CompareOutcome {
|
|||||||
Differed,
|
Differed,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
|
enum DocKind {
|
||||||
|
Html,
|
||||||
|
Json,
|
||||||
|
}
|
||||||
|
|
||||||
impl CompareOutcome {
|
impl CompareOutcome {
|
||||||
fn should_error(&self) -> bool {
|
fn should_error(&self) -> bool {
|
||||||
matches!(self, CompareOutcome::Differed)
|
matches!(self, CompareOutcome::Differed)
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
use super::TestCx;
|
use super::{DocKind, TestCx};
|
||||||
|
|
||||||
impl TestCx<'_> {
|
impl TestCx<'_> {
|
||||||
pub(super) fn run_rustdoc_js_test(&self) {
|
pub(super) fn run_rustdoc_js_test(&self) {
|
||||||
if let Some(nodejs) = &self.config.nodejs {
|
if let Some(nodejs) = &self.config.nodejs {
|
||||||
let out_dir = self.output_base_dir();
|
let out_dir = self.output_base_dir();
|
||||||
|
|
||||||
self.document(&out_dir, &self.testpaths);
|
self.document(&out_dir, &self.testpaths, DocKind::Html);
|
||||||
|
|
||||||
let file_stem = self.testpaths.file.file_stem().expect("no file stem");
|
let file_stem = self.testpaths.file.file_stem().expect("no file stem");
|
||||||
let res = self.run_command_to_procres(
|
let res = self.run_command_to_procres(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
use super::{TestCx, remove_and_create_dir_all};
|
use super::{DocKind, TestCx, remove_and_create_dir_all};
|
||||||
|
|
||||||
impl TestCx<'_> {
|
impl TestCx<'_> {
|
||||||
pub(super) fn run_rustdoc_test(&self) {
|
pub(super) fn run_rustdoc_test(&self) {
|
||||||
@@ -11,7 +11,7 @@ impl TestCx<'_> {
|
|||||||
panic!("failed to remove and recreate output directory `{out_dir}`: {e}")
|
panic!("failed to remove and recreate output directory `{out_dir}`: {e}")
|
||||||
});
|
});
|
||||||
|
|
||||||
let proc_res = self.document(&out_dir, &self.testpaths);
|
let proc_res = self.document(&out_dir, &self.testpaths, DocKind::Html);
|
||||||
if !proc_res.status.success() {
|
if !proc_res.status.success() {
|
||||||
self.fatal_proc_rec("rustdoc failed!", &proc_res);
|
self.fatal_proc_rec("rustdoc failed!", &proc_res);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
use super::{TestCx, remove_and_create_dir_all};
|
use super::{DocKind, TestCx, remove_and_create_dir_all};
|
||||||
|
|
||||||
impl TestCx<'_> {
|
impl TestCx<'_> {
|
||||||
pub(super) fn run_rustdoc_json_test(&self) {
|
pub(super) fn run_rustdoc_json_test(&self) {
|
||||||
@@ -13,7 +13,7 @@ impl TestCx<'_> {
|
|||||||
panic!("failed to remove and recreate output directory `{out_dir}`: {e}")
|
panic!("failed to remove and recreate output directory `{out_dir}`: {e}")
|
||||||
});
|
});
|
||||||
|
|
||||||
let proc_res = self.document(&out_dir, &self.testpaths);
|
let proc_res = self.document(&out_dir, &self.testpaths, DocKind::Json);
|
||||||
if !proc_res.status.success() {
|
if !proc_res.status.success() {
|
||||||
self.fatal_proc_rec("rustdoc failed!", &proc_res);
|
self.fatal_proc_rec("rustdoc failed!", &proc_res);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user