diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2021-05-07 00:38:37 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-07 00:38:37 +0200 |
| commit | 577f1d007d99064fea5f20c4bd2814b38ee7fe48 (patch) | |
| tree | f8a5bbfbc26dd8aef30a87a50660c0c7f5f47c3f /src/tools/compiletest | |
| parent | 3a0d6bec56966e8566d0249cd56dd37192a538e4 (diff) | |
| parent | 947ad5838c08c5609f619b96d0baa197cd20f4b0 (diff) | |
| download | rust-577f1d007d99064fea5f20c4bd2814b38ee7fe48.tar.gz rust-577f1d007d99064fea5f20c4bd2814b38ee7fe48.zip | |
Rollup merge of #84734 - tmandry:compiletest-needs-unwind, r=Mark-Simulacrum
Add `needs-unwind` and beginning of support for testing `panic=abort` std to compiletest For the Fuchsia platform we build libstd with `panic=abort` and would like a way to run tests with that enabled. This adds low-level support for this directly to compiletest. In the future I'd like to add high-level support in rustbuild, e.g. having target-specific flags that allow configuring a panic strategy. (Side note: It would be nice if we could also build multiple configurations for the same target, but I'm getting ahead of myself.) This plus #84500 have everything that's needed to get ui tests passing on fuchsia targets. Part of #84766. Note that this change only includes the header on tests which need an unwinder to _build_, not those which need it to _run_. r? ````@Mark-Simulacrum````
Diffstat (limited to 'src/tools/compiletest')
| -rw-r--r-- | src/tools/compiletest/src/common.rs | 10 | ||||
| -rw-r--r-- | src/tools/compiletest/src/header.rs | 8 | ||||
| -rw-r--r-- | src/tools/compiletest/src/main.rs | 18 |
3 files changed, 30 insertions, 6 deletions
diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 2a14d8a3999..408c0b8da0b 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -171,6 +171,12 @@ impl fmt::Display for Debugger { } } +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum PanicStrategy { + Unwind, + Abort, +} + /// Configuration for compiletest #[derive(Debug, Clone)] pub struct Config { @@ -265,6 +271,10 @@ pub struct Config { /// Flags to pass to the compiler when building for the target pub target_rustcflags: Option<String>, + /// What panic strategy the target is built with. Unwind supports Abort, but + /// not vice versa. + pub target_panic: PanicStrategy, + /// Target system to be tested pub target: String, diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 56527420c0d..983934d129a 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -7,7 +7,7 @@ use std::path::{Path, PathBuf}; use tracing::*; -use crate::common::{CompareMode, Config, Debugger, FailMode, Mode, PassMode}; +use crate::common::{CompareMode, Config, Debugger, FailMode, Mode, PanicStrategy, PassMode}; use crate::util; use crate::{extract_cdb_version, extract_gdb_version}; @@ -115,6 +115,12 @@ impl EarlyProps { props.ignore = true; } + if config.target_panic == PanicStrategy::Abort + && config.parse_name_directive(ln, "needs-unwind") + { + props.ignore = true; + } + if config.target == "wasm32-unknown-unknown" && config.parse_check_run_results(ln) { props.ignore = true; } diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index f42f9fb237a..d53e19f2908 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -5,7 +5,9 @@ extern crate test; -use crate::common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS}; +use crate::common::{ + expected_output_path, output_base_dir, output_relative_path, PanicStrategy, UI_EXTENSIONS, +}; use crate::common::{CompareMode, Config, Debugger, Mode, PassMode, Pretty, TestPaths}; use crate::util::logv; use getopts::Options; @@ -97,8 +99,9 @@ pub fn parse_config(args: Vec<String>) -> Config { (eg. emulator, valgrind)", "PROGRAM", ) - .optopt("", "host-rustcflags", "flags to pass to rustc for host", "FLAGS") - .optopt("", "target-rustcflags", "flags to pass to rustc for target", "FLAGS") + .optmulti("", "host-rustcflags", "flags to pass to rustc for host", "FLAGS") + .optmulti("", "target-rustcflags", "flags to pass to rustc for target", "FLAGS") + .optopt("", "target-panic", "what panic strategy the target supports", "unwind | abort") .optflag("", "verbose", "run tests verbosely, showing all output") .optflag( "", @@ -243,8 +246,13 @@ pub fn parse_config(args: Vec<String>) -> Config { }), logfile: matches.opt_str("logfile").map(|s| PathBuf::from(&s)), runtool: matches.opt_str("runtool"), - host_rustcflags: matches.opt_str("host-rustcflags"), - target_rustcflags: matches.opt_str("target-rustcflags"), + host_rustcflags: Some(matches.opt_strs("host-rustcflags").join(" ")), + target_rustcflags: Some(matches.opt_strs("target-rustcflags").join(" ")), + target_panic: match matches.opt_str("target-panic").as_deref() { + Some("unwind") | None => PanicStrategy::Unwind, + Some("abort") => PanicStrategy::Abort, + _ => panic!("unknown `--target-panic` option `{}` given", mode), + }, target, host: opt_str2(matches.opt_str("host")), cdb, |
