Skip to content

Commit da6d82e

Browse files
Simplify build system for rustdoc-gui test crates
1 parent 8ccee61 commit da6d82e

File tree

9 files changed

+65
-14
lines changed

9 files changed

+65
-14
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,7 @@ __pycache__/
7272
**node_modules
7373
**package-lock.json
7474

75+
## Rustdoc GUI tests
76+
src/test/rustdoc-gui/src/**.lock
77+
7578
# Before adding new lines, see the comment at the top.

src/bootstrap/test.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -907,27 +907,25 @@ impl Step for RustdocGUI {
907907
// We remove existing folder to be sure there won't be artifacts remaining.
908908
let _ = fs::remove_dir_all(&out_dir);
909909

910-
let mut nb_generated = 0;
910+
let src_path = "src/test/rustdoc-gui/src";
911911
// We generate docs for the libraries present in the rustdoc-gui's src folder.
912-
let libs_dir = builder.build.src.join("src/test/rustdoc-gui/src");
913-
for entry in libs_dir.read_dir().expect("read_dir call failed") {
914-
let entry = entry.expect("invalid entry");
915-
let path = entry.path();
916-
if path.extension().map(|e| e == "rs").unwrap_or(false) {
917-
let mut command = builder.rustdoc_cmd(self.compiler);
918-
command.arg(path).arg("-o").arg(&out_dir);
919-
builder.run(&mut command);
920-
nb_generated += 1;
921-
}
922-
}
923-
assert!(nb_generated > 0, "no documentation was generated...");
912+
let mut cargo = Command::new(&builder.initial_cargo);
913+
cargo
914+
.arg("doc")
915+
.arg("--workspace")
916+
.arg("--target-dir")
917+
.arg(&out_dir)
918+
.env("RUSTDOC", builder.rustdoc(self.compiler))
919+
.env("RUSTC", builder.rustc(self.compiler))
920+
.current_dir(&builder.build.src.join(src_path));
921+
builder.run(&mut cargo);
924922

925923
// We now run GUI tests.
926924
let mut command = Command::new(&nodejs);
927925
command
928926
.arg(builder.build.src.join("src/tools/rustdoc-gui/tester.js"))
929927
.arg("--doc-folder")
930-
.arg(out_dir)
928+
.arg(out_dir.join("doc"))
931929
.arg("--tests-folder")
932930
.arg(builder.build.src.join("src/test/rustdoc-gui"));
933931
for path in &builder.paths {

src/test/rustdoc-gui/src/Cargo.lock

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This file is automatically @generated by Cargo.
2+
# It is not intended for manual editing.
3+
version = 3
4+
5+
[[package]]
6+
name = "implementors"
7+
version = "0.1.0"
8+
9+
[[package]]
10+
name = "lib2"
11+
version = "0.1.0"
12+
dependencies = [
13+
"implementors",
14+
]
15+
16+
[[package]]
17+
name = "test_docs"
18+
version = "0.1.0"

src/test/rustdoc-gui/src/Cargo.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[workspace]
2+
members = [
3+
"test_docs",
4+
"lib2",
5+
"implementors",
6+
]
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "lib2"
3+
version = "0.1.0"
4+
edition = "2018"
5+
6+
[lib]
7+
path = "lib.rs"
8+
9+
[dependencies]
10+
implementors = { path = "../implementors" }

src/test/rustdoc-gui/src/lib2.rs src/test/rustdoc-gui/src/lib2/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ impl Trait for Foo {
3131
type X = u32;
3232
const Y: u32 = 0;
3333
}
34+
35+
impl implementors::Whatever for Foo {}
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#[cfg(test)]
2+
mod tests {
3+
#[test]
4+
fn it_works() {
5+
assert_eq!(2 + 2, 4);
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "test_docs"
3+
version = "0.1.0"
4+
edition = "2018"
5+
6+
[lib]
7+
path = "lib.rs"
File renamed without changes.

0 commit comments

Comments
 (0)