compiletest/runtest/rustdoc.rs
1use super::{DocKind, TestCx, remove_and_create_dir_all};
2use crate::util::ArgFileCommand;
3
4fn has_test_flag(flags: &[String]) -> bool {
5 flags.iter().any(|s| s == "--test")
6}
7
8impl TestCx<'_> {
9 pub(super) fn run_rustdoc_html_test(&self) {
10 assert!(self.variant.revision.is_none(), "revisions not supported in this test suite");
11
12 if has_test_flag(&self.props.compile_flags) || has_test_flag(&self.props.doc_flags) {
13 panic!(
14 "If you want to check `--test`, put this test into `rustdoc-ui` testsuite instead",
15 );
16 }
17 if self.props.should_fail {
18 panic!("`should-fail` should not be used in `rustdoc-html` testsuite");
19 }
20 let out_dir = self.output_base_dir();
21 remove_and_create_dir_all(&out_dir).unwrap_or_else(|e| {
22 panic!("failed to remove and recreate output directory `{out_dir}`: {e}")
23 });
24
25 let proc_res = self.document(&out_dir, DocKind::Html);
26 if !proc_res.status.success() {
27 self.fatal_proc_rec("rustdoc failed!", &proc_res);
28 }
29
30 if self.props.check_test_line_numbers_match {
31 self.check_rustdoc_test_option(proc_res);
32 } else {
33 let mut cmd = ArgFileCommand::new(&self.config.python);
34 cmd.arg(self.config.src_root.join("src/etc/htmldocck.py"))
35 .arg(&out_dir)
36 .arg(&self.testpaths.file);
37 if self.config.bless {
38 cmd.arg("--bless");
39 }
40 let res = self.run_command_to_procres(cmd);
41 if !res.status.success() {
42 self.fatal_proc_rec("htmldocck failed!", &res);
43 }
44 }
45 }
46}