Skip to content

Commit 07fe4e6

Browse files
Migrate run-make/doctests-keep-binaries to new rmake.rs format
1 parent 68f527b commit 07fe4e6

File tree

3 files changed

+71
-34
lines changed

3 files changed

+71
-34
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ run-make/dep-graph/Makefile
4444
run-make/dep-info-doesnt-run-much/Makefile
4545
run-make/dep-info-spaces/Makefile
4646
run-make/dep-info/Makefile
47-
run-make/doctests-keep-binaries/Makefile
4847
run-make/doctests-runtool/Makefile
4948
run-make/dump-ice-to-disk/Makefile
5049
run-make/dump-mono-stats/Makefile

tests/run-make/doctests-keep-binaries/Makefile

-33
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Check that valid binaries are persisted by running them, regardless of whether the
2+
// --run or --no-run option is used.
3+
4+
use run_make_support::{run, rustc, rustdoc, tmp_dir};
5+
use std::fs::{create_dir, remove_dir_all};
6+
use std::path::Path;
7+
8+
fn setup_test_env<F: FnOnce(&Path, &Path)>(callback: F) {
9+
let out_dir = tmp_dir().join("doctests");
10+
create_dir(&out_dir).expect("failed to create doctests folder");
11+
rustc()
12+
.input("t.rs")
13+
.crate_type("rlib")
14+
.run();
15+
callback(&out_dir, &tmp_dir().join("libt.rlib"));
16+
remove_dir_all(out_dir);
17+
}
18+
19+
fn check_generated_binaries() {
20+
run("doctests/t_rs_2_0/rust_out");
21+
run("doctests/t_rs_8_0/rust_out");
22+
}
23+
24+
fn main() {
25+
setup_test_env(|out_dir, extern_path| {
26+
rustdoc()
27+
.input("t.rs")
28+
.arg("-Zunstable-options")
29+
.arg("--test")
30+
.arg("--persist-doctests")
31+
.arg(out_dir)
32+
.arg("--extern")
33+
.arg(format!("t={}", extern_path.display()))
34+
.run();
35+
check_generated_binaries();
36+
});
37+
setup_test_env(|out_dir, extern_path| {
38+
rustdoc()
39+
.input("t.rs")
40+
.arg("-Zunstable-options")
41+
.arg("--test")
42+
.arg("--persist-doctests")
43+
.arg(out_dir)
44+
.arg("--extern")
45+
.arg(format!("t={}", extern_path.display()))
46+
.arg("--no-run")
47+
.run();
48+
check_generated_binaries();
49+
});
50+
// Behavior with --test-run-directory with relative paths.
51+
setup_test_env(|_out_dir, extern_path| {
52+
let run_dir = "rundir";
53+
let run_dir_path = tmp_dir().join("rundir");
54+
create_dir(&run_dir_path).expect("failed to create rundir folder");
55+
56+
rustdoc()
57+
.current_dir(tmp_dir())
58+
.input(std::env::current_dir().unwrap().join("t.rs"))
59+
.arg("-Zunstable-options")
60+
.arg("--test")
61+
.arg("--persist-doctests")
62+
.arg("doctests")
63+
.arg("--test-run-directory")
64+
.arg(run_dir)
65+
.arg("--extern")
66+
.arg("t=libt.rlib")
67+
.run();
68+
69+
remove_dir_all(run_dir_path);
70+
});
71+
}

0 commit comments

Comments
 (0)