Skip to content

Commit a78341a

Browse files
committed
compiletest: Refactor: Move the ignore-{} logic into its own method.
Prepare for `normalize-std???` which will share the same logic. Added `ignore-32bit` and `ignore-64bit`.
1 parent 54fc9e4 commit a78341a

File tree

3 files changed

+35
-36
lines changed

3 files changed

+35
-36
lines changed

src/test/run-pass/i128-ffi.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@
1313
// should look like.
1414

1515
// ignore-windows
16-
17-
// Ignore 32 bit targets:
18-
// ignore-x86
19-
// ignore-arm
20-
21-
// ignore-emscripten
16+
// ignore-32bit
2217

2318
#![feature(i128_type)]
2419

src/tools/compiletest/src/header.rs

+26-30
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,8 @@ impl EarlyProps {
4040
None,
4141
&mut |ln| {
4242
props.ignore =
43-
props.ignore || config.parse_name_directive(ln, "ignore-test") ||
44-
config.parse_name_directive(ln, &ignore_target(config)) ||
45-
config.parse_name_directive(ln, &ignore_architecture(config)) ||
46-
config.parse_name_directive(ln, &ignore_stage(config)) ||
47-
config.parse_name_directive(ln, &ignore_env(config)) ||
48-
(config.mode == common::Pretty &&
49-
config.parse_name_directive(ln, "ignore-pretty")) ||
50-
(config.target != config.host &&
51-
config.parse_name_directive(ln, "ignore-cross-compile")) ||
43+
props.ignore ||
44+
config.parse_cfg_name_directive(ln, "ignore") ||
5245
ignore_gdb(config, ln) ||
5346
ignore_lldb(config, ln) ||
5447
ignore_llvm(config, ln);
@@ -62,28 +55,11 @@ impl EarlyProps {
6255

6356
return props;
6457

65-
fn ignore_target(config: &Config) -> String {
66-
format!("ignore-{}", util::get_os(&config.target))
67-
}
68-
fn ignore_architecture(config: &Config) -> String {
69-
format!("ignore-{}", util::get_arch(&config.target))
70-
}
71-
fn ignore_stage(config: &Config) -> String {
72-
format!("ignore-{}", config.stage_id.split('-').next().unwrap())
73-
}
74-
fn ignore_env(config: &Config) -> String {
75-
format!("ignore-{}",
76-
util::get_env(&config.target).unwrap_or("<unknown>"))
77-
}
7858
fn ignore_gdb(config: &Config, line: &str) -> bool {
7959
if config.mode != common::DebugInfoGdb {
8060
return false;
8161
}
8262

83-
if config.parse_name_directive(line, "ignore-gdb") {
84-
return true;
85-
}
86-
8763
if let Some(actual_version) = config.gdb_version {
8864
if line.starts_with("min-gdb-version") {
8965
let (start_ver, end_ver) = extract_gdb_version_range(line);
@@ -144,10 +120,6 @@ impl EarlyProps {
144120
return false;
145121
}
146122

147-
if config.parse_name_directive(line, "ignore-lldb") {
148-
return true;
149-
}
150-
151123
if let Some(ref actual_version) = config.lldb_version {
152124
if line.starts_with("min-lldb-version") {
153125
let min_version = line.trim_right()
@@ -525,6 +497,30 @@ impl Config {
525497
}
526498
}
527499

500+
/// Parses a name-value directive which contains config-specific information, e.g. `ignore-x86`
501+
/// or `normalize-stderr-32bit`. Returns `true` if the line matches it.
502+
fn parse_cfg_name_directive(&self, line: &str, prefix: &str) -> bool {
503+
if line.starts_with(prefix) && line.as_bytes().get(prefix.len()) == Some(&b'-') {
504+
let name = line[prefix.len()+1 ..].split(&[':', ' '][..]).next().unwrap();
505+
506+
name == "test" ||
507+
name == util::get_os(&self.target) || // target
508+
name == util::get_arch(&self.target) || // architecture
509+
name == util::get_pointer_width(&self.target) || // pointer width
510+
name == self.stage_id.split('-').next().unwrap() || // stage
511+
Some(name) == util::get_env(&self.target) || // env
512+
match self.mode {
513+
common::DebugInfoGdb => name == "gdb",
514+
common::DebugInfoLldb => name == "lldb",
515+
common::Pretty => name == "pretty",
516+
_ => false,
517+
} ||
518+
(self.target != self.host && name == "cross-compile")
519+
} else {
520+
false
521+
}
522+
}
523+
528524
fn parse_name_directive(&self, line: &str, directive: &str) -> bool {
529525
// Ensure the directive is a whole word. Do not match "ignore-x86" when
530526
// the line says "ignore-x86_64".

src/tools/compiletest/src/util.rs

+8
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ pub fn get_env(triple: &str) -> Option<&str> {
7272
triple.split('-').nth(3)
7373
}
7474

75+
pub fn get_pointer_width(triple: &str) -> &'static str {
76+
if triple.contains("64") || triple.starts_with("s390x") {
77+
"64bit"
78+
} else {
79+
"32bit"
80+
}
81+
}
82+
7583
pub fn make_new_path(path: &str) -> String {
7684
assert!(cfg!(windows));
7785
// Windows just uses PATH as the library search path, so we have to

0 commit comments

Comments
 (0)