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
**package-lock.json
## Rustdoc GUI tests
src/test/rustdoc-gui/src/**.lock
# 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.
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.
let libs_dir = builder.build.src.join("src/test/rustdoc-gui/src");
for entry in libs_dir.read_dir().expect("read_dir call failed") {
let entry = entry.expect("invalid entry");
let path = entry.path();
if path.extension().map(|e| e == "rs").unwrap_or(false) {
let mut command = builder.rustdoc_cmd(self.compiler);
command.arg(path).arg("-o").arg(&out_dir);
builder.run(&mut command);
nb_generated += 1;
}
}
assert!(nb_generated > 0, "no documentation was generated...");
let mut cargo = Command::new(&builder.initial_cargo);
cargo
.arg("doc")
.arg("--workspace")
.arg("--target-dir")
.arg(&out_dir)
.env("RUSTDOC", builder.rustdoc(self.compiler))
.env("RUSTC", builder.rustc(self.compiler))
.current_dir(&builder.build.src.join(src_path));
builder.run(&mut cargo);
// We now run GUI tests.
let mut command = Command::new(&nodejs);
command
.arg(builder.build.src.join("src/tools/rustdoc-gui/tester.js"))
.arg("--doc-folder")
.arg(out_dir)
.arg(out_dir.join("doc"))
.arg("--tests-folder")
.arg(builder.build.src.join("src/test/rustdoc-gui"));
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;
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"