Skip to content

Commit 72c9580

Browse files
Rollup merge of rust-lang#124658 - GuillaumeGomez:migrate-to-run-make, r=jieyouxu
Migrate `run-make/doctests-keep-binaries` to new rmake.rs format r? ``@jieyouxu``
2 parents bfa1f59 + 5ea65c8 commit 72c9580

File tree

4 files changed

+74
-34
lines changed

4 files changed

+74
-34
lines changed

src/tools/run-make-support/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,12 @@ macro_rules! impl_common_helpers {
261261
}
262262
output
263263
}
264+
265+
/// Set the path where the command will be run.
266+
pub fn current_dir<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
267+
self.cmd.current_dir(path);
268+
self
269+
}
264270
}
265271
};
266272
}

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,68 @@
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().input("t.rs").crate_type("rlib").run();
12+
callback(&out_dir, &tmp_dir().join("libt.rlib"));
13+
remove_dir_all(out_dir);
14+
}
15+
16+
fn check_generated_binaries() {
17+
run("doctests/t_rs_2_0/rust_out");
18+
run("doctests/t_rs_8_0/rust_out");
19+
}
20+
21+
fn main() {
22+
setup_test_env(|out_dir, extern_path| {
23+
rustdoc()
24+
.input("t.rs")
25+
.arg("-Zunstable-options")
26+
.arg("--test")
27+
.arg("--persist-doctests")
28+
.arg(out_dir)
29+
.arg("--extern")
30+
.arg(format!("t={}", extern_path.display()))
31+
.run();
32+
check_generated_binaries();
33+
});
34+
setup_test_env(|out_dir, extern_path| {
35+
rustdoc()
36+
.input("t.rs")
37+
.arg("-Zunstable-options")
38+
.arg("--test")
39+
.arg("--persist-doctests")
40+
.arg(out_dir)
41+
.arg("--extern")
42+
.arg(format!("t={}", extern_path.display()))
43+
.arg("--no-run")
44+
.run();
45+
check_generated_binaries();
46+
});
47+
// Behavior with --test-run-directory with relative paths.
48+
setup_test_env(|_out_dir, extern_path| {
49+
let run_dir = "rundir";
50+
let run_dir_path = tmp_dir().join("rundir");
51+
create_dir(&run_dir_path).expect("failed to create rundir folder");
52+
53+
rustdoc()
54+
.current_dir(tmp_dir())
55+
.input(std::env::current_dir().unwrap().join("t.rs"))
56+
.arg("-Zunstable-options")
57+
.arg("--test")
58+
.arg("--persist-doctests")
59+
.arg("doctests")
60+
.arg("--test-run-directory")
61+
.arg(run_dir)
62+
.arg("--extern")
63+
.arg("t=libt.rlib")
64+
.run();
65+
66+
remove_dir_all(run_dir_path);
67+
});
68+
}

0 commit comments

Comments
 (0)