compiletest/runtest/
rustdoc_json.rs

1use std::process::Command;
2
3use super::{TestCx, remove_and_create_dir_all};
4
5impl TestCx<'_> {
6    pub(super) fn run_rustdoc_json_test(&self) {
7        //FIXME: Add bless option.
8
9        assert!(self.revision.is_none(), "revisions not relevant here");
10
11        let out_dir = self.output_base_dir();
12        remove_and_create_dir_all(&out_dir).unwrap_or_else(|e| {
13            panic!("failed to remove and recreate output directory `{out_dir}`: {e}")
14        });
15
16        let proc_res = self.document(&out_dir, &self.testpaths);
17        if !proc_res.status.success() {
18            self.fatal_proc_rec("rustdoc failed!", &proc_res);
19        }
20
21        let mut json_out = out_dir.join(self.testpaths.file.file_stem().unwrap());
22        json_out.set_extension("json");
23        let res = self.run_command_to_procres(
24            Command::new(self.config.jsondocck_path.as_ref().unwrap())
25                .arg("--doc-dir")
26                .arg(&out_dir)
27                .arg("--template")
28                .arg(&self.testpaths.file),
29        );
30
31        if !res.status.success() {
32            self.fatal_proc_rec_with_ctx("jsondocck failed!", &res, |_| {
33                println!("Rustdoc Output:");
34                proc_res.print_info();
35            })
36        }
37
38        let mut json_out = out_dir.join(self.testpaths.file.file_stem().unwrap());
39        json_out.set_extension("json");
40
41        let res = self.run_command_to_procres(
42            Command::new(self.config.jsondoclint_path.as_ref().unwrap()).arg(&json_out),
43        );
44
45        if !res.status.success() {
46            self.fatal_proc_rec("jsondoclint failed!", &res);
47        }
48    }
49}