Simplify build system for rustdoc-gui test crates

This commit is contained in:
Guillaume Gomez 2021-07-10 21:09:51 +02:00
parent 8ccee61d38
commit da6d82e465
9 changed files with 65 additions and 14 deletions

3
.gitignore vendored
View File

@ -72,4 +72,7 @@ __pycache__/
**node_modules **node_modules
**package-lock.json **package-lock.json
## Rustdoc GUI tests
src/test/rustdoc-gui/src/**.lock
# Before adding new lines, see the comment at the top. # Before adding new lines, see the comment at the top.

View File

@ -907,27 +907,25 @@ fn run(self, builder: &Builder<'_>) {
// We remove existing folder to be sure there won't be artifacts remaining. // We remove existing folder to be sure there won't be artifacts remaining.
let _ = fs::remove_dir_all(&out_dir); let _ = fs::remove_dir_all(&out_dir);
let mut nb_generated = 0; let src_path = "src/test/rustdoc-gui/src";
// We generate docs for the libraries present in the rustdoc-gui's src folder. // We generate docs for the libraries present in the rustdoc-gui's src folder.
let libs_dir = builder.build.src.join("src/test/rustdoc-gui/src"); let mut cargo = Command::new(&builder.initial_cargo);
for entry in libs_dir.read_dir().expect("read_dir call failed") { cargo
let entry = entry.expect("invalid entry"); .arg("doc")
let path = entry.path(); .arg("--workspace")
if path.extension().map(|e| e == "rs").unwrap_or(false) { .arg("--target-dir")
let mut command = builder.rustdoc_cmd(self.compiler); .arg(&out_dir)
command.arg(path).arg("-o").arg(&out_dir); .env("RUSTDOC", builder.rustdoc(self.compiler))
builder.run(&mut command); .env("RUSTC", builder.rustc(self.compiler))
nb_generated += 1; .current_dir(&builder.build.src.join(src_path));
} builder.run(&mut cargo);
}
assert!(nb_generated > 0, "no documentation was generated...");
// We now run GUI tests. // We now run GUI tests.
let mut command = Command::new(&nodejs); let mut command = Command::new(&nodejs);
command command
.arg(builder.build.src.join("src/tools/rustdoc-gui/tester.js")) .arg(builder.build.src.join("src/tools/rustdoc-gui/tester.js"))
.arg("--doc-folder") .arg("--doc-folder")
.arg(out_dir) .arg(out_dir.join("doc"))
.arg("--tests-folder") .arg("--tests-folder")
.arg(builder.build.src.join("src/test/rustdoc-gui")); .arg(builder.build.src.join("src/test/rustdoc-gui"));
for path in &builder.paths { for path in &builder.paths {

View File

@ -0,0 +1,18 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "implementors"
version = "0.1.0"
[[package]]
name = "lib2"
version = "0.1.0"
dependencies = [
"implementors",
]
[[package]]
name = "test_docs"
version = "0.1.0"

View File

@ -0,0 +1,6 @@
[workspace]
members = [
"test_docs",
"lib2",
"implementors",
]

View File

@ -0,0 +1,10 @@
[package]
name = "lib2"
version = "0.1.0"
edition = "2018"
[lib]
path = "lib.rs"
[dependencies]
implementors = { path = "../implementors" }

View File

@ -31,3 +31,5 @@ impl Trait for Foo {
type X = u32; type X = u32;
const Y: u32 = 0; const Y: u32 = 0;
} }
impl implementors::Whatever for Foo {}

View File

@ -0,0 +1,7 @@
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}

View File

@ -0,0 +1,7 @@
[package]
name = "test_docs"
version = "0.1.0"
edition = "2018"
[lib]
path = "lib.rs"