compiletest/runtest/rustdoc.rs
1use std::process::Command;
2
3use super::{TestCx, remove_and_create_dir_all};
4
5impl TestCx<'_> {
6 pub(super) fn run_rustdoc_test(&self) {
7 assert!(self.revision.is_none(), "revisions not relevant here");
8
9 let out_dir = self.output_base_dir();
10 remove_and_create_dir_all(&out_dir).unwrap_or_else(|e| {
11 panic!("failed to remove and recreate output directory `{out_dir}`: {e}")
12 });
13
14 let proc_res = self.document(&out_dir, &self.testpaths);
15 if !proc_res.status.success() {
16 self.fatal_proc_rec("rustdoc failed!", &proc_res);
17 }
18
19 if self.props.check_test_line_numbers_match {
20 self.check_rustdoc_test_option(proc_res);
21 } else {
22 let mut cmd = Command::new(&self.config.python);
23 cmd.arg(self.config.src_root.join("src/etc/htmldocck.py"))
24 .arg(&out_dir)
25 .arg(&self.testpaths.file);
26 if self.config.bless {
27 cmd.arg("--bless");
28 }
29 let res = self.run_command_to_procres(&mut cmd);
30 if !res.status.success() {
31 self.fatal_proc_rec_with_ctx("htmldocck failed!", &res, |mut this| {
32 this.compare_to_default_rustdoc(&out_dir)
33 });
34 }
35 }
36 }
37}