mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Add target.*.runner
configuration for targets
This commit adds a `runner` field configuration to `config.toml` for specifying a wrapper executable when executing binaries for a target. This is pulled out of #122036 where a WebAssembly runtime is used, for example, to execute tests for `wasm32-wasip1`. The name "runner" here is chosen to match Cargo's `CARGO_*_RUNNER` configuration, and to make things a bit more consistent this additionally renames compiletest's `--runtool` argument to `--runner`.
This commit is contained in:
parent
42825768b1
commit
dd95cb7106
@ -842,6 +842,17 @@
|
|||||||
# See that option for more info.
|
# See that option for more info.
|
||||||
#codegen-backends = rust.codegen-backends (array)
|
#codegen-backends = rust.codegen-backends (array)
|
||||||
|
|
||||||
|
# This is a "runner" to pass to `compiletest` when executing tests. Tests will
|
||||||
|
# execute this tool where the binary-to-test is passed as an argument. Can
|
||||||
|
# be useful for situations such as when WebAssembly is being tested and a
|
||||||
|
# runtime needs to be configured. This value is similar to
|
||||||
|
# Cargo's `CARGO_$target_RUNNER` configuration.
|
||||||
|
#
|
||||||
|
# This configuration is a space-separated list of arguments so `foo bar` would
|
||||||
|
# execute the program `foo` with the first argument as `bar` and the second
|
||||||
|
# argument as the test binary.
|
||||||
|
#runner = <none> (string)
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Distribution options
|
# Distribution options
|
||||||
#
|
#
|
||||||
|
@ -1970,6 +1970,8 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
|
|||||||
|
|
||||||
if builder.remote_tested(target) {
|
if builder.remote_tested(target) {
|
||||||
cmd.arg("--remote-test-client").arg(builder.tool_exe(Tool::RemoteTestClient));
|
cmd.arg("--remote-test-client").arg(builder.tool_exe(Tool::RemoteTestClient));
|
||||||
|
} else if let Some(tool) = builder.runner(target) {
|
||||||
|
cmd.arg("--runner").arg(tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
if suite != "mir-opt" {
|
if suite != "mir-opt" {
|
||||||
@ -2519,6 +2521,8 @@ fn prepare_cargo_test(
|
|||||||
format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)),
|
format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)),
|
||||||
format!("{} run 0", builder.tool_exe(Tool::RemoteTestClient).display()),
|
format!("{} run 0", builder.tool_exe(Tool::RemoteTestClient).display()),
|
||||||
);
|
);
|
||||||
|
} else if let Some(tool) = builder.runner(target) {
|
||||||
|
cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
cargo
|
cargo
|
||||||
|
@ -579,6 +579,7 @@ pub struct Target {
|
|||||||
pub musl_libdir: Option<PathBuf>,
|
pub musl_libdir: Option<PathBuf>,
|
||||||
pub wasi_root: Option<PathBuf>,
|
pub wasi_root: Option<PathBuf>,
|
||||||
pub qemu_rootfs: Option<PathBuf>,
|
pub qemu_rootfs: Option<PathBuf>,
|
||||||
|
pub runner: Option<String>,
|
||||||
pub no_std: bool,
|
pub no_std: bool,
|
||||||
pub codegen_backends: Option<Vec<Interned<String>>>,
|
pub codegen_backends: Option<Vec<Interned<String>>>,
|
||||||
}
|
}
|
||||||
@ -1142,6 +1143,7 @@ define_config! {
|
|||||||
qemu_rootfs: Option<String> = "qemu-rootfs",
|
qemu_rootfs: Option<String> = "qemu-rootfs",
|
||||||
no_std: Option<bool> = "no-std",
|
no_std: Option<bool> = "no-std",
|
||||||
codegen_backends: Option<Vec<String>> = "codegen-backends",
|
codegen_backends: Option<Vec<String>> = "codegen-backends",
|
||||||
|
runner: Option<String> = "runner",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1862,6 +1864,7 @@ impl Config {
|
|||||||
target.musl_libdir = cfg.musl_libdir.map(PathBuf::from);
|
target.musl_libdir = cfg.musl_libdir.map(PathBuf::from);
|
||||||
target.wasi_root = cfg.wasi_root.map(PathBuf::from);
|
target.wasi_root = cfg.wasi_root.map(PathBuf::from);
|
||||||
target.qemu_rootfs = cfg.qemu_rootfs.map(PathBuf::from);
|
target.qemu_rootfs = cfg.qemu_rootfs.map(PathBuf::from);
|
||||||
|
target.runner = cfg.runner;
|
||||||
target.sanitizers = cfg.sanitizers;
|
target.sanitizers = cfg.sanitizers;
|
||||||
target.profiler = cfg.profiler;
|
target.profiler = cfg.profiler;
|
||||||
target.rpath = cfg.rpath;
|
target.rpath = cfg.rpath;
|
||||||
|
@ -1353,6 +1353,17 @@ impl Build {
|
|||||||
|| env::var_os("TEST_DEVICE_ADDR").is_some()
|
|| env::var_os("TEST_DEVICE_ADDR").is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns an optional "runner" to pass to `compiletest` when executing
|
||||||
|
/// test binaries.
|
||||||
|
///
|
||||||
|
/// An example of this would be a WebAssembly runtime when testing the wasm
|
||||||
|
/// targets.
|
||||||
|
fn runner(&self, target: TargetSelection) -> Option<String> {
|
||||||
|
let target = self.config.target_config.get(&target)?;
|
||||||
|
let runner = target.runner.as_ref()?;
|
||||||
|
Some(runner.to_owned())
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the root of the "rootfs" image that this target will be using,
|
/// Returns the root of the "rootfs" image that this target will be using,
|
||||||
/// if one was configured.
|
/// if one was configured.
|
||||||
///
|
///
|
||||||
|
@ -266,8 +266,10 @@ pub struct Config {
|
|||||||
pub logfile: Option<PathBuf>,
|
pub logfile: Option<PathBuf>,
|
||||||
|
|
||||||
/// A command line to prefix program execution with,
|
/// A command line to prefix program execution with,
|
||||||
/// for running under valgrind
|
/// for running under valgrind for example.
|
||||||
pub runtool: Option<String>,
|
///
|
||||||
|
/// Similar to `CARGO_*_RUNNER` configuration.
|
||||||
|
pub runner: Option<String>,
|
||||||
|
|
||||||
/// Flags to pass to the compiler when building for the host
|
/// Flags to pass to the compiler when building for the host
|
||||||
pub host_rustcflags: Vec<String>,
|
pub host_rustcflags: Vec<String>,
|
||||||
|
@ -86,7 +86,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
|
|||||||
.optflag("", "exact", "filters match exactly")
|
.optflag("", "exact", "filters match exactly")
|
||||||
.optopt(
|
.optopt(
|
||||||
"",
|
"",
|
||||||
"runtool",
|
"runner",
|
||||||
"supervisor program to run tests under \
|
"supervisor program to run tests under \
|
||||||
(eg. emulator, valgrind)",
|
(eg. emulator, valgrind)",
|
||||||
"PROGRAM",
|
"PROGRAM",
|
||||||
@ -256,7 +256,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
|
|||||||
_ => panic!("unknown `--run` option `{}` given", mode),
|
_ => panic!("unknown `--run` option `{}` given", mode),
|
||||||
}),
|
}),
|
||||||
logfile: matches.opt_str("logfile").map(|s| PathBuf::from(&s)),
|
logfile: matches.opt_str("logfile").map(|s| PathBuf::from(&s)),
|
||||||
runtool: matches.opt_str("runtool"),
|
runner: matches.opt_str("runner"),
|
||||||
host_rustcflags: matches.opt_strs("host-rustcflags"),
|
host_rustcflags: matches.opt_strs("host-rustcflags"),
|
||||||
target_rustcflags: matches.opt_strs("target-rustcflags"),
|
target_rustcflags: matches.opt_strs("target-rustcflags"),
|
||||||
optimize_tests: matches.opt_present("optimize-tests"),
|
optimize_tests: matches.opt_present("optimize-tests"),
|
||||||
@ -341,7 +341,7 @@ pub fn log_config(config: &Config) {
|
|||||||
c,
|
c,
|
||||||
format!("force_pass_mode: {}", opt_str(&config.force_pass_mode.map(|m| format!("{}", m))),),
|
format!("force_pass_mode: {}", opt_str(&config.force_pass_mode.map(|m| format!("{}", m))),),
|
||||||
);
|
);
|
||||||
logv(c, format!("runtool: {}", opt_str(&config.runtool)));
|
logv(c, format!("runner: {}", opt_str(&config.runner)));
|
||||||
logv(c, format!("host-rustcflags: {:?}", config.host_rustcflags));
|
logv(c, format!("host-rustcflags: {:?}", config.host_rustcflags));
|
||||||
logv(c, format!("target-rustcflags: {:?}", config.target_rustcflags));
|
logv(c, format!("target-rustcflags: {:?}", config.target_rustcflags));
|
||||||
logv(c, format!("target: {}", config.target));
|
logv(c, format!("target: {}", config.target));
|
||||||
|
@ -461,7 +461,7 @@ impl<'test> TestCx<'test> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut new_config = self.config.clone();
|
let mut new_config = self.config.clone();
|
||||||
new_config.runtool = new_config.valgrind_path.clone();
|
new_config.runner = new_config.valgrind_path.clone();
|
||||||
let new_cx = TestCx { config: &new_config, ..*self };
|
let new_cx = TestCx { config: &new_config, ..*self };
|
||||||
proc_res = new_cx.exec_compiled_test();
|
proc_res = new_cx.exec_compiled_test();
|
||||||
|
|
||||||
@ -2647,7 +2647,7 @@ impl<'test> TestCx<'test> {
|
|||||||
fn make_run_args(&self) -> ProcArgs {
|
fn make_run_args(&self) -> ProcArgs {
|
||||||
// If we've got another tool to run under (valgrind),
|
// If we've got another tool to run under (valgrind),
|
||||||
// then split apart its command
|
// then split apart its command
|
||||||
let mut args = self.split_maybe_args(&self.config.runtool);
|
let mut args = self.split_maybe_args(&self.config.runner);
|
||||||
|
|
||||||
// If this is emscripten, then run tests under nodejs
|
// If this is emscripten, then run tests under nodejs
|
||||||
if self.config.target.contains("emscripten") {
|
if self.config.target.contains("emscripten") {
|
||||||
|
Loading…
Reference in New Issue
Block a user