Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,8 +1000,15 @@ impl<'test> TestCx<'test> {

/// `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.
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 {
assert_eq!(kind, DocKind::Html, "build-aux-docs doesn't make sense for rustdoc json");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:
Since the plan is to add postcard wouldn't it make sense to invert the statement? build-aux-docs only makes sense for rustdoc HTML, this way the message is still valid after postcard is introduced.


for rel_ab in &self.props.aux.builds {
let aux_testpaths = self.compute_aux_test_paths(root_testpaths, rel_ab);
let props_for_aux =
Expand All @@ -1018,7 +1025,7 @@ impl<'test> TestCx<'test> {
create_dir_all(aux_cx.output_base_dir()).unwrap();
// use root_testpaths here, because aux-builds should have the
// 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() {
return auxres;
}
Expand Down Expand Up @@ -1063,8 +1070,11 @@ impl<'test> TestCx<'test> {
.args(&self.props.compile_flags)
.args(&self.props.doc_flags);

if self.config.mode == TestMode::RustdocJson {
rustdoc.arg("--output-format").arg("json").arg("-Zunstable-options");
match kind {
DocKind::Html => {}
DocKind::Json => {
rustdoc.arg("--output-format").arg("json").arg("-Zunstable-options");
}
}

if let Some(ref linker) = self.config.target_linker {
Expand Down Expand Up @@ -2203,7 +2213,7 @@ impl<'test> TestCx<'test> {
let aux_dir = new_rustdoc.aux_output_dir();
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() {
writeln!(self.stderr, "failed to run nightly rustdoc");
return;
Expand Down Expand Up @@ -3121,6 +3131,12 @@ enum CompareOutcome {
Differed,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum DocKind {
Html,
Json,
}

impl CompareOutcome {
fn should_error(&self) -> bool {
matches!(self, CompareOutcome::Differed)
Expand Down
4 changes: 2 additions & 2 deletions src/tools/compiletest/src/runtest/js_doc.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::process::Command;

use super::TestCx;
use super::{DocKind, TestCx};

impl TestCx<'_> {
pub(super) fn run_rustdoc_js_test(&self) {
if let Some(nodejs) = &self.config.nodejs {
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 res = self.run_command_to_procres(
Expand Down
4 changes: 2 additions & 2 deletions src/tools/compiletest/src/runtest/rustdoc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::process::Command;

use super::{TestCx, remove_and_create_dir_all};
use super::{DocKind, TestCx, remove_and_create_dir_all};

impl TestCx<'_> {
pub(super) fn run_rustdoc_test(&self) {
Expand All @@ -11,7 +11,7 @@ impl TestCx<'_> {
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() {
self.fatal_proc_rec("rustdoc failed!", &proc_res);
}
Expand Down
4 changes: 2 additions & 2 deletions src/tools/compiletest/src/runtest/rustdoc_json.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::process::Command;

use super::{TestCx, remove_and_create_dir_all};
use super::{DocKind, TestCx, remove_and_create_dir_all};

impl TestCx<'_> {
pub(super) fn run_rustdoc_json_test(&self) {
Expand All @@ -13,7 +13,7 @@ impl TestCx<'_> {
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() {
self.fatal_proc_rec("rustdoc failed!", &proc_res);
}
Expand Down
Loading