diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-02-28 18:08:48 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-02-28 18:08:48 +0100 |
| commit | 405d95080288dc760e117a506278d968d57dfe09 (patch) | |
| tree | ba273434a12fb8f022888f3847e75f5ea7c11a1f /src/tools/compiletest | |
| parent | 240fad04f1c5517d5d38ab62c321f09c35a468d1 (diff) | |
| download | rust-405d95080288dc760e117a506278d968d57dfe09.tar.gz rust-405d95080288dc760e117a506278d968d57dfe09.zip | |
Move rustdoc-js testing into compiletest
Diffstat (limited to 'src/tools/compiletest')
| -rw-r--r-- | src/tools/compiletest/src/common.rs | 3 | ||||
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 29 |
2 files changed, 28 insertions, 4 deletions
diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 6b3117a1f74..f0991c8cdb5 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -24,6 +24,7 @@ pub enum Mode { Incremental, RunMake, Ui, + JsDocTest, MirOpt, } @@ -59,6 +60,7 @@ impl FromStr for Mode { "incremental" => Ok(Incremental), "run-make" => Ok(RunMake), "ui" => Ok(Ui), + "js-doc-test" => Ok(JsDocTest), "mir-opt" => Ok(MirOpt), _ => Err(()), } @@ -82,6 +84,7 @@ impl fmt::Display for Mode { Incremental => "incremental", RunMake => "run-make", Ui => "ui", + JsDocTest => "js-doc-test", MirOpt => "mir-opt", }; fmt::Display::fmt(s, f) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index bac41a7c579..f7c02e831a9 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -4,7 +4,7 @@ use crate::common::{output_base_dir, output_base_name, output_testname_unique}; use crate::common::{Codegen, CodegenUnits, DebugInfoBoth, DebugInfoGdb, DebugInfoLldb, Rustdoc}; use crate::common::{CompileFail, Pretty, RunFail, RunPass, RunPassValgrind}; use crate::common::{Config, TestPaths}; -use crate::common::{Incremental, MirOpt, RunMake, Ui}; +use crate::common::{Incremental, MirOpt, RunMake, Ui, JsDocTest}; use diff; use crate::errors::{self, Error, ErrorKind}; use filetime::FileTime; @@ -275,6 +275,7 @@ impl<'test> TestCx<'test> { RunMake => self.run_rmake_test(), RunPass | Ui => self.run_ui_test(), MirOpt => self.run_mir_opt_test(), + JsDocTest => self.run_js_doc_test(), } } @@ -290,7 +291,7 @@ impl<'test> TestCx<'test> { fn should_compile_successfully(&self) -> bool { match self.config.mode { CompileFail => self.props.compile_pass, - RunPass => true, + RunPass | JsDocTest => true, Ui => self.props.compile_pass, Incremental => { let revision = self.revision @@ -1712,7 +1713,8 @@ impl<'test> TestCx<'test> { } fn make_compile_args(&self, input_file: &Path, output_file: TargetLocation) -> Command { - let is_rustdoc = self.config.src_base.ends_with("rustdoc-ui"); + let is_rustdoc = self.config.src_base.ends_with("rustdoc-ui") || + self.config.src_base.ends_with("rustdoc-js"); let mut rustc = if !is_rustdoc { Command::new(&self.config.rustc_path) } else { @@ -1802,7 +1804,7 @@ impl<'test> TestCx<'test> { rustc.arg(dir_opt); } RunFail | RunPassValgrind | Pretty | DebugInfoBoth | DebugInfoGdb | DebugInfoLldb - | Codegen | Rustdoc | RunMake | CodegenUnits => { + | Codegen | Rustdoc | RunMake | CodegenUnits | JsDocTest => { // do not use JSON output } } @@ -2710,6 +2712,25 @@ impl<'test> TestCx<'test> { fs::remove_dir(path) } + fn run_js_doc_test(&self) { + if let Some(nodejs) = &self.config.nodejs { + let out_dir = self.output_base_dir(); + + self.document(&out_dir); + + let root = self.config.find_rust_src_root().unwrap(); + let res = self.cmd2procres( + Command::new(&nodejs) + .arg(root.join("src/tools/rustdoc-js/tester.js")) + .arg(out_dir.parent().expect("no parent")) + .arg(&self.testpaths.file.file_stem().expect("couldn't get file stem")), + ); + if !res.status.success() { + self.fatal_proc_rec("rustdoc-js test failed!", &res); + } + } + } + fn run_ui_test(&self) { // if the user specified a format in the ui test // print the output to the stderr file, otherwise extract |
