Rename --runtool and --runtool-arg

This renames `--runtool` and `--runtool-arg` to `--test-runtool` and
`--test-runtool-arg` to maintain consistency with other `--test-*`
arguments.
This commit is contained in:
Eric Huss
2025-02-15 10:50:47 -08:00
parent 0340a865b9
commit ec25e3300b
9 changed files with 29 additions and 29 deletions
+3 -3
View File
@@ -666,21 +666,21 @@ struct Foo;
In older versions, this will be ignored on all targets, but on newer versions `ignore-gnu` will
override `ignore`.
## `--runtool`, `--runtool-arg`: program to run tests with; args to pass to it
## `--test-runtool`, `--test-runtool-arg`: program to run tests with; args to pass to it
* Tracking issue: [#64245](https://github.com/rust-lang/rust/issues/64245)
Using these options looks like this:
```bash
$ rustdoc src/lib.rs -Z unstable-options --runtool runner --runtool-arg --do-thing --runtool-arg --do-other-thing
$ rustdoc src/lib.rs -Z unstable-options --test-runtool runner --test-runtool-arg --do-thing --test-runtool-arg --do-other-thing
```
These options can be used to run the doctest under a program, and also pass arguments to
that program. For example, if you want to run your doctests under valgrind you might run
```bash
$ rustdoc src/lib.rs -Z unstable-options --runtool valgrind
$ rustdoc src/lib.rs -Z unstable-options --test-runtool valgrind
```
Another use case would be to run a test inside an emulator, or through a Virtual Machine.
+8 -8
View File
@@ -124,9 +124,9 @@ pub(crate) struct Options {
/// temporary directory if not set.
pub(crate) persist_doctests: Option<PathBuf>,
/// Runtool to run doctests with
pub(crate) runtool: Option<String>,
pub(crate) test_runtool: Option<String>,
/// Arguments to pass to the runtool
pub(crate) runtool_args: Vec<String>,
pub(crate) test_runtool_args: Vec<String>,
/// Whether to allow ignoring doctests on a per-target basis
/// For example, using ignore-foo to ignore running the doctest on any target that
/// contains "foo" as a substring
@@ -215,8 +215,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
.field("persist_doctests", &self.persist_doctests)
.field("show_coverage", &self.show_coverage)
.field("crate_version", &self.crate_version)
.field("runtool", &self.runtool)
.field("runtool_args", &self.runtool_args)
.field("test_runtool", &self.test_runtool)
.field("test_runtool_args", &self.test_runtool_args)
.field("enable-per-target-ignores", &self.enable_per_target_ignores)
.field("run_check", &self.run_check)
.field("no_run", &self.no_run)
@@ -779,8 +779,8 @@ fn println_condition(condition: Condition) {
let unstable_opts_strs = matches.opt_strs("Z");
let lib_strs = matches.opt_strs("L");
let extern_strs = matches.opt_strs("extern");
let runtool = matches.opt_str("runtool");
let runtool_args = matches.opt_strs("runtool-arg");
let test_runtool = matches.opt_str("test-runtool");
let test_runtool_args = matches.opt_strs("test-runtool-arg");
let enable_per_target_ignores = matches.opt_present("enable-per-target-ignores");
let document_private = matches.opt_present("document-private-items");
let document_hidden = matches.opt_present("document-hidden-items");
@@ -843,8 +843,8 @@ fn println_condition(condition: Condition) {
crate_version,
test_run_directory,
persist_doctests,
runtool,
runtool_args,
test_runtool,
test_runtool_args,
enable_per_target_ignores,
test_builder,
run_check,
+2 -2
View File
@@ -781,10 +781,10 @@ fn drop(&mut self) {
let mut cmd;
let output_file = make_maybe_absolute_path(output_file);
if let Some(tool) = &rustdoc_options.runtool {
if let Some(tool) = &rustdoc_options.test_runtool {
let tool = make_maybe_absolute_path(tool.into());
cmd = Command::new(tool);
cmd.args(&rustdoc_options.runtool_args);
cmd.args(&rustdoc_options.test_runtool_args);
cmd.arg(&output_file);
} else {
cmd = Command::new(&output_file);
+2 -2
View File
@@ -518,7 +518,7 @@ fn opts() -> Vec<RustcOptGroup> {
Unstable,
Opt,
"",
"runtool",
"test-runtool",
"",
"The tool to run tests with when building for a different target than host",
),
@@ -526,7 +526,7 @@ fn opts() -> Vec<RustcOptGroup> {
Unstable,
Multi,
"",
"runtool-arg",
"test-runtool-arg",
"",
"One (of possibly many) arguments to pass to the runtool",
),
+1 -1
View File
@@ -53,7 +53,7 @@ fn main() {
// with `RustcPhase::Rustdoc`. There we perform a check-build (needed to get the expected
// build failures for `compile_fail` doctests) and then store a JSON file with the
// information needed to run this test.
// - We also set `--runtool` to ourselves, which ends up in `phase_runner` with
// - We also set `--test-runtool` to ourselves, which ends up in `phase_runner` with
// `RunnerPhase::Rustdoc`. There we parse the JSON file written in `phase_rustc` and invoke
// the Miri driver for interpretation.
+5 -5
View File
@@ -666,8 +666,8 @@ pub fn phase_rustdoc(mut args: impl Iterator<Item = String>) {
if arg == "--extern" {
// Patch --extern arguments to use *.rmeta files, since phase_cargo_rustc only creates stub *.rlib files.
forward_patched_extern_arg(&mut args, &mut cmd);
} else if arg == "--runtool" {
// An existing --runtool flag indicates cargo is running in cross-target mode, which we don't support.
} else if arg == "--test-runtool" {
// An existing --test-runtool flag indicates cargo is running in cross-target mode, which we don't support.
// Note that this is only passed when cargo is run with the unstable -Zdoctest-xcompile flag;
// otherwise, we won't be called as rustdoc at all.
show_error!("cross-interpreting doctests is not currently supported by Miri.");
@@ -693,8 +693,8 @@ pub fn phase_rustdoc(mut args: impl Iterator<Item = String>) {
// to let phase_cargo_rustc know to expect that. We'll use this environment variable as a flag:
cmd.env("MIRI_CALLED_FROM_RUSTDOC", "1");
// The `--test-builder` and `--runtool` arguments are unstable rustdoc features,
// which are disabled by default. We first need to enable them explicitly:
// The `--test-builder` is an unstable rustdoc features,
// which is disabled by default. We first need to enable them explicitly:
cmd.arg("-Zunstable-options");
// rustdoc needs to know the right sysroot.
@@ -705,7 +705,7 @@ pub fn phase_rustdoc(mut args: impl Iterator<Item = String>) {
// Make rustdoc call us back.
let cargo_miri_path = env::current_exe().expect("current executable path invalid");
cmd.arg("--test-builder").arg(&cargo_miri_path); // invoked by forwarding most arguments
cmd.arg("--runtool").arg(&cargo_miri_path); // invoked with just a single path argument
cmd.arg("--test-runtool").arg(&cargo_miri_path); // invoked with just a single path argument
debug_cmd("[cargo-miri rustdoc]", verbose, &cmd);
exec(cmd)
+3 -3
View File
@@ -1,4 +1,4 @@
// Tests behavior of rustdoc `--runtool`.
// Tests behavior of rustdoc `--test-runtool`.
use std::path::PathBuf;
@@ -11,7 +11,7 @@ fn mkdir(name: &str) -> PathBuf {
dir
}
// Behavior with --runtool with relative paths and --test-run-directory.
// Behavior with --test-runtool with relative paths and --test-run-directory.
fn main() {
let run_dir_name = "rundir";
let run_dir = mkdir(run_dir_name);
@@ -27,7 +27,7 @@ fn main() {
.arg("--test")
.arg("--test-run-directory")
.arg(run_dir_name)
.arg("--runtool")
.arg("--test-runtool")
.arg(&run_tool_binary)
.extern_("t", "libt.rlib")
.run();
@@ -141,9 +141,9 @@ Options:
--enable-per-target-ignores
parse ignore-foo for ignoring doctests on a per-target
basis
--runtool The tool to run tests with when building for a different target than host
--test-runtool The tool to run tests with when building for a different target than host
--runtool-arg One (of possibly many) arguments to pass to the runtool
--test-runtool-arg One (of possibly many) arguments to pass to the runtool
--test-builder PATH
The rustc-like binary to use as the test builder
+3 -3
View File
@@ -1,10 +1,10 @@
// Tests that the --runtool argument works.
// Tests that the --test-runtool argument works.
//@ ignore-cross-compile
//@ aux-bin: doctest-runtool.rs
//@ compile-flags: --test
//@ compile-flags: --runtool=auxiliary/bin/doctest-runtool
//@ compile-flags: --runtool-arg=arg1 --runtool-arg
//@ compile-flags: --test-runtool=auxiliary/bin/doctest-runtool
//@ compile-flags: --test-runtool-arg=arg1 --test-runtool-arg
//@ compile-flags: 'arg2 with space'
//@ compile-flags: -Zunstable-options