compiletest/runtest/
rustdoc_json.rs1use std::process::Command;
2
3use super::{DocKind, TestCx, remove_and_create_dir_all};
4
5impl TestCx<'_> {
6 pub(super) fn run_rustdoc_json_test(&self) {
7 assert!(self.revision.is_none(), "revisions not supported in this test suite");
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, DocKind::Json);
17 if !proc_res.status.success() {
18 self.fatal_proc_rec("rustdoc failed!", &proc_res);
19 }
20
21 let res = self.run_command_to_procres(
22 Command::new(self.config.jsondocck_path.as_ref().unwrap())
23 .arg("--doc-dir")
24 .arg(&out_dir)
25 .arg("--template")
26 .arg(&self.testpaths.file),
27 );
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 res = self.run_command_to_procres(
40 Command::new(self.config.jsondoclint_path.as_ref().unwrap()).arg(&json_out),
41 );
42
43 if !res.status.success() {
44 self.fatal_proc_rec("jsondoclint failed!", &res);
45 }
46 }
47}