From 7715656edd201b8c6bbddf0040f424c27e4db4df Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Fri, 15 Jan 2021 20:34:15 -0500 Subject: Add jsondocck tool, and use it for rustdoc JSON --- src/tools/compiletest/src/common.rs | 3 +++ src/tools/compiletest/src/header/tests.rs | 1 + src/tools/compiletest/src/main.rs | 3 +++ src/tools/compiletest/src/runtest.rs | 22 +++++++++++----------- 4 files changed, 18 insertions(+), 11 deletions(-) (limited to 'src/tools/compiletest') diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 43dbaeb4655..4cefb562b13 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -198,6 +198,9 @@ pub struct Config { /// The Python executable to use for htmldocck. pub docck_python: String, + /// The jsondocck executable. + pub jsondocck_path: String, + /// The LLVM `FileCheck` binary path. pub llvm_filecheck: Option, diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index 4bcbd89f095..ec99fde0df9 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -45,6 +45,7 @@ fn config() -> Config { "--rustc-path=", "--lldb-python=", "--docck-python=", + "--jsondocck-path=", "--src-base=", "--build-base=", "--stage-id=stage2", diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index aefcfe222e5..03a443c8bff 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -60,6 +60,7 @@ pub fn parse_config(args: Vec) -> Config { .optopt("", "rust-demangler-path", "path to rust-demangler to use in tests", "PATH") .reqopt("", "lldb-python", "path to python to use for doc tests", "PATH") .reqopt("", "docck-python", "path to python to use for doc tests", "PATH") + .reqopt("", "jsondocck-path", "path to jsondocck to use for doc tests", "PATH") .optopt("", "valgrind-path", "path to Valgrind executable for Valgrind tests", "PROGRAM") .optflag("", "force-valgrind", "fail if Valgrind tests cannot be run under Valgrind") .optopt("", "run-clang-based-tests-with", "path to Clang executable", "PATH") @@ -196,6 +197,7 @@ pub fn parse_config(args: Vec) -> Config { let has_tidy = Command::new("tidy") .arg("--version") .stdout(Stdio::null()) + .stderr(Stdio::null()) .status() .map_or(false, |status| status.success()); Config { @@ -207,6 +209,7 @@ pub fn parse_config(args: Vec) -> Config { rust_demangler_path: matches.opt_str("rust-demangler-path").map(PathBuf::from), lldb_python: matches.opt_str("lldb-python").unwrap(), docck_python: matches.opt_str("docck-python").unwrap(), + jsondocck_path: matches.opt_str("jsondocck-path").unwrap(), valgrind_path: matches.opt_str("valgrind-path"), force_valgrind: matches.opt_present("force-valgrind"), run_clang_based_tests_with: matches.opt_str("run-clang-based-tests-with"), diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 9f31b3ae1b1..b15a563a930 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2490,27 +2490,27 @@ impl<'test> TestCx<'test> { let mut json_out = out_dir.join(self.testpaths.file.file_stem().unwrap()); json_out.set_extension("json"); let res = self.cmd2procres( - Command::new(&self.config.docck_python) - .arg(root.join("src/test/rustdoc-json/check_missing_items.py")) - .arg(&json_out), + Command::new(&self.config.jsondocck_path) + .arg("--doc-dir") + .arg(root.join(&out_dir)) + .arg("--template") + .arg(&self.testpaths.file), ); if !res.status.success() { - self.fatal_proc_rec("check_missing_items failed!", &res); + self.fatal_proc_rec("jsondocck failed!", &res) } - let mut expected = self.testpaths.file.clone(); - expected.set_extension("expected"); + let mut json_out = out_dir.join(self.testpaths.file.file_stem().unwrap()); + json_out.set_extension("json"); let res = self.cmd2procres( Command::new(&self.config.docck_python) - .arg(root.join("src/test/rustdoc-json/compare.py")) - .arg(&expected) - .arg(&json_out) - .arg(&expected.parent().unwrap()), + .arg(root.join("src/etc/check_missing_items.py")) + .arg(&json_out), ); if !res.status.success() { - self.fatal_proc_rec("compare failed!", &res); + self.fatal_proc_rec("check_missing_items failed!", &res); } } -- cgit 1.4.1-3-g733a5