compiletest/runtest/
rustdoc_json.rs1use super::{DocKind, TestCx, remove_and_create_dir_all};
2use crate::util::ArgFileCommand;
3
4impl TestCx<'_> {
5 pub(super) fn run_rustdoc_json_test(&self) {
6 assert!(self.revision.is_none(), "revisions not supported in this test suite");
9
10 let out_dir = self.output_base_dir();
11 remove_and_create_dir_all(&out_dir).unwrap_or_else(|e| {
12 panic!("failed to remove and recreate output directory `{out_dir}`: {e}")
13 });
14
15 let proc_res = self.document(&out_dir, DocKind::Json);
16
17 if !self.config.capture {
18 writeln!(self.stdout, "{}", proc_res.format_info());
19 }
20
21 if !proc_res.status.success() {
22 self.fatal_proc_rec("rustdoc failed!", &proc_res);
23 }
24
25 let mut cmd = ArgFileCommand::new(self.config.jsondocck_path.as_ref().unwrap());
26 cmd.arg("--doc-dir").arg(&out_dir).arg("--template").arg(&self.testpaths.file);
27 let res = self.run_command_to_procres(cmd);
28
29 if !res.status.success() {
30 self.fatal_proc_rec_general("jsondocck failed!", None, &res, || {
31 writeln!(self.stdout, "Rustdoc Output:");
32 writeln!(self.stdout, "{}", proc_res.format_info());
33 })
34 }
35
36 let mut json_out = out_dir.join(self.testpaths.file.file_stem().unwrap());
37 json_out.set_extension("json");
38
39 let mut cmd = ArgFileCommand::new(self.config.jsondoclint_path.as_ref().unwrap());
40 cmd.arg(&json_out);
41 let res = self.run_command_to_procres(cmd);
42
43 if !res.status.success() {
44 self.fatal_proc_rec("jsondoclint failed!", &res);
45 }
46 }
47}