diff options
| author | bors <bors@rust-lang.org> | 2021-02-22 06:47:59 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-02-22 06:47:59 +0000 |
| commit | 352238d152b6b3f106554e75445bbdd5201671b2 (patch) | |
| tree | 146cb88c6a6c29e8f94b7aa17a07874d5b6bc230 /src/bootstrap | |
| parent | e952db8fd02090a10024ae63ba9d34e3b9cef898 (diff) | |
| parent | 20f2497efd5e74bdbf775f8de144ed5c3e3394e8 (diff) | |
| download | rust-352238d152b6b3f106554e75445bbdd5201671b2.tar.gz rust-352238d152b6b3f106554e75445bbdd5201671b2.zip | |
Auto merge of #79979 - GuillaumeGomez:rustdoc-gui-tests, r=Mark-Simulacrum
Rustdoc gui tests This is a reopening of #70533. For this first version, there will be no screenshot comparison. Also, a big change compared to the previous version: the tests are now hosted in the rust repository directly. Since there is no image, it's pretty lightweight to say the least. So now, only remains the nodejs script to run the tests and the tests themselves. Just one thing is missing: where should I put the documentation for these tests? I'm not sure where would be the best place for that. The doc will contain important information like the documentation of the framework used and how to install it (`npm install browser-ui-test`, but still needs to be put somewhere so no one is lost). We'd also need to install the package when running the CI too. For now, it runs as long as we have nodejs installed, but I think we don't it to run in all nodejs targets? cc `@jyn514` r? `@Mark-Simulacrum`
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/builder.rs | 1 | ||||
| -rw-r--r-- | src/bootstrap/config.rs | 3 | ||||
| -rw-r--r-- | src/bootstrap/lib.rs | 4 | ||||
| -rw-r--r-- | src/bootstrap/mk/Makefile.in | 4 | ||||
| -rw-r--r-- | src/bootstrap/sanity.rs | 7 | ||||
| -rw-r--r-- | src/bootstrap/test.rs | 75 |
6 files changed, 94 insertions, 0 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index a9099981e64..08f10fbd794 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -440,6 +440,7 @@ impl<'a> Builder<'a> { test::CompiletestTest, test::RustdocJSStd, test::RustdocJSNotStd, + test::RustdocGUI, test::RustdocTheme, test::RustdocUi, test::RustdocJson, diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index e4b8269f94c..d50d605d5c6 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -174,6 +174,7 @@ pub struct Config { pub mandir: Option<PathBuf>, pub codegen_tests: bool, pub nodejs: Option<PathBuf>, + pub npm: Option<PathBuf>, pub gdb: Option<PathBuf>, pub python: Option<PathBuf>, pub cargo_native_static: bool, @@ -364,6 +365,7 @@ struct Build { fast_submodules: Option<bool>, gdb: Option<String>, nodejs: Option<String>, + npm: Option<String>, python: Option<String>, locked_deps: Option<bool>, vendor: Option<bool>, @@ -654,6 +656,7 @@ impl Config { }; config.nodejs = build.nodejs.map(PathBuf::from); + config.npm = build.npm.map(PathBuf::from); config.gdb = build.gdb.map(PathBuf::from); config.python = build.python.map(PathBuf::from); set(&mut config.low_priority, build.low_priority); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 88fdcfa2d43..5d708d3b25c 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -637,6 +637,10 @@ impl Build { self.out.join(&*target.triple).join("doc") } + fn test_out(&self, target: TargetSelection) -> PathBuf { + self.out.join(&*target.triple).join("test") + } + /// Output directory for all documentation for a target fn compiler_doc_out(&self, target: TargetSelection) -> PathBuf { self.out.join(&*target.triple).join("compiler-doc") diff --git a/src/bootstrap/mk/Makefile.in b/src/bootstrap/mk/Makefile.in index fd39944e176..47cf1172d36 100644 --- a/src/bootstrap/mk/Makefile.in +++ b/src/bootstrap/mk/Makefile.in @@ -45,6 +45,10 @@ check-aux: src/tools/cargo \ src/tools/cargotest \ $(BOOTSTRAP_ARGS) +check-aux-and-gui: check-aux + $(Q)$(BOOTSTRAP) test --stage 2 \ + src/test/rustdoc-gui \ + $(BOOTSTRAP_ARGS) check-bootstrap: $(Q)$(CFG_PYTHON) $(CFG_SRC_DIR)src/bootstrap/bootstrap_test.py dist: diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs index 08acc3d671f..ed0cbdf97b0 100644 --- a/src/bootstrap/sanity.rs +++ b/src/bootstrap/sanity.rs @@ -113,6 +113,13 @@ pub fn check(build: &mut Build) { .or_else(|| cmd_finder.maybe_have("node")) .or_else(|| cmd_finder.maybe_have("nodejs")); + build.config.npm = build + .config + .npm + .take() + .map(|p| cmd_finder.must_have(p)) + .or_else(|| cmd_finder.maybe_have("npm")); + build.config.gdb = build .config .gdb diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 7830dc82394..49d56f4cbdf 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -688,6 +688,78 @@ impl Step for RustdocJSNotStd { } } +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct RustdocGUI { + pub target: TargetSelection, + pub compiler: Compiler, +} + +impl Step for RustdocGUI { + type Output = (); + const DEFAULT: bool = true; + const ONLY_HOSTS: bool = true; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.path("src/test/rustdoc-gui") + } + + fn make_run(run: RunConfig<'_>) { + let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple()); + run.builder.ensure(RustdocGUI { target: run.target, compiler }); + } + + fn run(self, builder: &Builder<'_>) { + if let (Some(nodejs), Some(npm)) = (&builder.config.nodejs, &builder.config.npm) { + builder.ensure(compile::Std { compiler: self.compiler, target: self.target }); + + // The goal here is to check if the necessary packages are installed, and if not, we + // display a warning and move on. + let mut command = Command::new(&npm); + command.arg("list").arg("--depth=0"); + let lines = command + .output() + .map(|output| String::from_utf8_lossy(&output.stdout).to_string()) + .unwrap_or(String::new()); + if !lines.contains(&" browser-ui-test@") { + println!( + "warning: rustdoc-gui test suite cannot be run because npm `browser-ui-test` \ + dependency is missing", + ); + println!( + "If you want to install the `{0}` dependency, run `npm install {0}`", + "browser-ui-test", + ); + return; + } + + let out_dir = builder.test_out(self.target).join("rustdoc-gui"); + let mut command = builder.rustdoc_cmd(self.compiler); + command.arg("src/test/rustdoc-gui/lib.rs").arg("-o").arg(&out_dir); + builder.run(&mut command); + + for file in fs::read_dir("src/test/rustdoc-gui").unwrap() { + let file = file.unwrap(); + let file_path = file.path(); + let file_name = file.file_name(); + + if !file_name.to_str().unwrap().ends_with(".goml") { + continue; + } + let mut command = Command::new(&nodejs); + command + .arg("src/tools/rustdoc-gui/tester.js") + .arg("--doc-folder") + .arg(out_dir.join("test_docs")) + .arg("--test-file") + .arg(file_path); + builder.run(&mut command); + } + } else { + builder.info("No nodejs found, skipping \"src/test/rustdoc-gui\" tests"); + } + } +} + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Tidy; @@ -1048,6 +1120,9 @@ note: if you're sure you want to do this, please open an issue as to why. In the if let Some(ref nodejs) = builder.config.nodejs { cmd.arg("--nodejs").arg(nodejs); } + if let Some(ref npm) = builder.config.npm { + cmd.arg("--npm").arg(npm); + } let mut flags = if is_rustdoc { Vec::new() } else { vec!["-Crpath".to_string()] }; if !is_rustdoc { |
