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 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);
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 let mut json_out = out_dir.join(self.testpaths.file.file_stem().unwrap());
20 json_out.set_extension("json");
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_with_ctx("jsondocck failed!", &res, |_| {
31 println!("Rustdoc Output:");
32 proc_res.print_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}