Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate run-make/doctests-keep-binaries to new rmake.rs format #124658

Merged
merged 2 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/tools/run-make-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ macro_rules! impl_common_helpers {
}
output
}

/// Set the path where the command will be run.
pub fn current_dir<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.cmd.current_dir(path);
self
}
}
};
}
Expand Down
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ run-make/dep-graph/Makefile
run-make/dep-info-doesnt-run-much/Makefile
run-make/dep-info-spaces/Makefile
run-make/dep-info/Makefile
run-make/doctests-keep-binaries/Makefile
run-make/doctests-runtool/Makefile
run-make/dump-ice-to-disk/Makefile
run-make/dump-mono-stats/Makefile
Expand Down
33 changes: 0 additions & 33 deletions tests/run-make/doctests-keep-binaries/Makefile

This file was deleted.

68 changes: 68 additions & 0 deletions tests/run-make/doctests-keep-binaries/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Check that valid binaries are persisted by running them, regardless of whether the
// --run or --no-run option is used.

use run_make_support::{run, rustc, rustdoc, tmp_dir};
use std::fs::{create_dir, remove_dir_all};
use std::path::Path;

fn setup_test_env<F: FnOnce(&Path, &Path)>(callback: F) {
let out_dir = tmp_dir().join("doctests");
create_dir(&out_dir).expect("failed to create doctests folder");
rustc().input("t.rs").crate_type("rlib").run();
callback(&out_dir, &tmp_dir().join("libt.rlib"));
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)
.arg("--extern")
.arg(format!("t={}", extern_path.display()))
jieyouxu marked this conversation as resolved.
Show resolved Hide resolved
.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)
.arg("--extern")
.arg(format!("t={}", extern_path.display()))
.arg("--no-run")
.run();
check_generated_binaries();
});
// Behavior with --test-run-directory with relative paths.
setup_test_env(|_out_dir, extern_path| {
let run_dir = "rundir";
let run_dir_path = tmp_dir().join("rundir");
create_dir(&run_dir_path).expect("failed to create rundir folder");

rustdoc()
.current_dir(tmp_dir())
.input(std::env::current_dir().unwrap().join("t.rs"))
.arg("-Zunstable-options")
.arg("--test")
.arg("--persist-doctests")
.arg("doctests")
.arg("--test-run-directory")
.arg(run_dir)
.arg("--extern")
.arg("t=libt.rlib")
.run();

remove_dir_all(run_dir_path);
});
}
Loading