Skip to content

Commit 568d9c5

Browse files
committed
compiletest: Add --target-panic, needs-unwind
1 parent bb491ed commit 568d9c5

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/tools/compiletest/src/common.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ impl fmt::Display for Debugger {
171171
}
172172
}
173173

174+
#[derive(Clone, Copy, Debug, PartialEq)]
175+
pub enum PanicStrategy {
176+
Unwind,
177+
Abort,
178+
}
179+
174180
/// Configuration for compiletest
175181
#[derive(Debug, Clone)]
176182
pub struct Config {
@@ -262,6 +268,10 @@ pub struct Config {
262268
/// Flags to pass to the compiler when building for the target
263269
pub target_rustcflags: Option<String>,
264270

271+
/// What panic strategy the target is built with. Unwind supports Abort, but
272+
/// not vice versa.
273+
pub target_panic: PanicStrategy,
274+
265275
/// Target system to be tested
266276
pub target: String,
267277

src/tools/compiletest/src/header.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::path::{Path, PathBuf};
77

88
use tracing::*;
99

10-
use crate::common::{CompareMode, Config, Debugger, FailMode, Mode, PassMode};
10+
use crate::common::{CompareMode, Config, Debugger, FailMode, Mode, PanicStrategy, PassMode};
1111
use crate::util;
1212
use crate::{extract_cdb_version, extract_gdb_version};
1313

@@ -111,6 +111,12 @@ impl EarlyProps {
111111
props.ignore = true;
112112
}
113113

114+
if config.target_panic == PanicStrategy::Abort
115+
&& config.parse_name_directive(ln, "needs-unwind")
116+
{
117+
props.ignore = true;
118+
}
119+
114120
if config.target == "wasm32-unknown-unknown" && config.parse_check_run_results(ln) {
115121
props.ignore = true;
116122
}

src/tools/compiletest/src/main.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
extern crate test;
77

8-
use crate::common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS};
8+
use crate::common::{
9+
expected_output_path, output_base_dir, output_relative_path, PanicStrategy, UI_EXTENSIONS,
10+
};
911
use crate::common::{CompareMode, Config, Debugger, Mode, PassMode, Pretty, TestPaths};
1012
use crate::util::logv;
1113
use getopts::Options;
@@ -98,6 +100,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
98100
)
99101
.optopt("", "host-rustcflags", "flags to pass to rustc for host", "FLAGS")
100102
.optopt("", "target-rustcflags", "flags to pass to rustc for target", "FLAGS")
103+
.optopt("", "target-panic", "what panic strategy the target supports", "unwind | abort")
101104
.optflag("", "verbose", "run tests verbosely, showing all output")
102105
.optflag(
103106
"",
@@ -238,6 +241,11 @@ pub fn parse_config(args: Vec<String>) -> Config {
238241
runtool: matches.opt_str("runtool"),
239242
host_rustcflags: matches.opt_str("host-rustcflags"),
240243
target_rustcflags: matches.opt_str("target-rustcflags"),
244+
target_panic: match matches.opt_str("target-panic").as_deref() {
245+
Some("unwind") | None => PanicStrategy::Unwind,
246+
Some("abort") => PanicStrategy::Abort,
247+
_ => panic!("unknown `--target-panic` option `{}` given", mode),
248+
},
241249
target,
242250
host: opt_str2(matches.opt_str("host")),
243251
cdb,

0 commit comments

Comments
 (0)