2024-05-03 08:13:08 -05:00
|
|
|
// Check that valid binaries are persisted by running them, regardless of whether the
|
|
|
|
// --run or --no-run option is used.
|
|
|
|
|
|
|
|
use std::path::Path;
|
2024-07-28 17:13:50 -05:00
|
|
|
|
2024-07-17 08:31:38 -05:00
|
|
|
use run_make_support::rfs::{create_dir, remove_dir_all};
|
2024-06-06 14:34:34 -05:00
|
|
|
use run_make_support::{run, rustc, rustdoc};
|
2024-05-03 08:13:08 -05:00
|
|
|
|
|
|
|
fn setup_test_env<F: FnOnce(&Path, &Path)>(callback: F) {
|
2024-06-06 14:34:34 -05:00
|
|
|
let out_dir = Path::new("doctests");
|
2024-06-06 13:47:00 -05:00
|
|
|
create_dir(&out_dir);
|
2024-05-03 08:13:08 -05:00
|
|
|
rustc().input("t.rs").crate_type("rlib").run();
|
2024-06-06 14:34:34 -05:00
|
|
|
callback(&out_dir, Path::new("libt.rlib"));
|
2024-05-03 08:13:08 -05:00
|
|
|
remove_dir_all(out_dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn check_generated_binaries() {
|
|
|
|
run("doctests/t_rs_2_0/rust_out");
|
|
|
|
run("doctests/t_rs_8_0/rust_out");
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
setup_test_env(|out_dir, extern_path| {
|
|
|
|
rustdoc()
|
|
|
|
.input("t.rs")
|
|
|
|
.arg("-Zunstable-options")
|
|
|
|
.arg("--test")
|
|
|
|
.arg("--persist-doctests")
|
|
|
|
.arg(out_dir)
|
2024-05-14 06:39:40 -05:00
|
|
|
.extern_("t", extern_path)
|
2024-05-03 08:13:08 -05:00
|
|
|
.run();
|
|
|
|
check_generated_binaries();
|
|
|
|
});
|
|
|
|
setup_test_env(|out_dir, extern_path| {
|
|
|
|
rustdoc()
|
|
|
|
.input("t.rs")
|
|
|
|
.arg("-Zunstable-options")
|
|
|
|
.arg("--test")
|
|
|
|
.arg("--persist-doctests")
|
|
|
|
.arg(out_dir)
|
2024-05-14 06:39:40 -05:00
|
|
|
.extern_("t", extern_path)
|
2024-05-03 08:13:08 -05:00
|
|
|
.arg("--no-run")
|
|
|
|
.run();
|
|
|
|
check_generated_binaries();
|
|
|
|
});
|
|
|
|
// Behavior with --test-run-directory with relative paths.
|
2024-06-06 13:47:00 -05:00
|
|
|
setup_test_env(|_out_dir, _extern_path| {
|
2024-06-06 14:34:34 -05:00
|
|
|
let run_dir_path = Path::new("rundir");
|
2024-06-06 13:47:00 -05:00
|
|
|
create_dir(&run_dir_path);
|
2024-05-03 08:13:08 -05:00
|
|
|
|
|
|
|
rustdoc()
|
2024-06-06 14:34:34 -05:00
|
|
|
.input("t.rs")
|
2024-05-03 08:13:08 -05:00
|
|
|
.arg("-Zunstable-options")
|
|
|
|
.arg("--test")
|
|
|
|
.arg("--persist-doctests")
|
|
|
|
.arg("doctests")
|
|
|
|
.arg("--test-run-directory")
|
2024-06-06 14:34:34 -05:00
|
|
|
.arg(run_dir_path)
|
2024-05-14 06:39:40 -05:00
|
|
|
.extern_("t", "libt.rlib")
|
2024-05-03 08:13:08 -05:00
|
|
|
.run();
|
|
|
|
|
|
|
|
remove_dir_all(run_dir_path);
|
|
|
|
});
|
|
|
|
}
|