Skip to content

Commit

Permalink
Merge pull request #249 from LykenSol/only
Browse files Browse the repository at this point in the history
Support `// only-*` and increase `// {only,ignore}-*` flexibility.
  • Loading branch information
Manishearth authored Nov 3, 2021
2 parents fdd8285 + 69cacd0 commit 4ab843a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
22 changes: 20 additions & 2 deletions src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,17 @@ impl EarlyProps {
&mut |ln| {
props.ignore =
props.ignore ||
config.parse_cfg_name_directive(ln, "ignore") ||
config.parse_cfg_name_directive(ln, "ignore");

if config.has_cfg_prefix(ln, "only") {
props.ignore = match config.parse_cfg_name_directive(ln, "only") {
true => props.ignore,
false => true,
};
}

props.ignore =
props.ignore ||
ignore_gdb(config, ln) ||
ignore_lldb(config, ln) ||
ignore_llvm(config, ln);
Expand Down Expand Up @@ -405,7 +415,7 @@ impl TestProps {
}
}
}

if let (Some(edition), false) = (&config.edition, has_edition) {
self.compile_flags.push(format!("--edition={}", edition));
}
Expand Down Expand Up @@ -579,6 +589,7 @@ impl Config {
name == util::get_pointer_width(&self.target) || // pointer width
name == self.stage_id.split('-').next().unwrap() || // stage
Some(name) == util::get_env(&self.target) || // env
self.target.ends_with(name) || // target and env
match self.mode {
common::DebugInfoGdb => name == "gdb",
common::DebugInfoLldb => name == "lldb",
Expand All @@ -591,6 +602,13 @@ impl Config {
}
}

fn has_cfg_prefix(&self, line: &str, prefix: &str) -> bool {
// returns whether this line contains this prefix or not. For prefix
// "ignore", returns true if line says "ignore-x86_64", "ignore-arch",
// "ignore-android" etc.
line.starts_with(prefix) && line.as_bytes().get(prefix.len()) == Some(&b'-')
}

fn parse_name_directive(&self, line: &str, directive: &str) -> bool {
// Ensure the directive is a whole word. Do not match "ignore-x86" when
// the line says "ignore-x86_64".
Expand Down
6 changes: 3 additions & 3 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ pub fn matches_os(triple: &str, name: &str) -> bool {
return os == name;
}
}
panic!("Cannot determine OS from triple");
false
}
pub fn get_arch(triple: &str) -> &'static str {
pub fn get_arch(triple: &str) -> &str {
for &(triple_arch, arch) in ARCH_TABLE {
if triple.contains(triple_arch) {
return arch;
}
}
panic!("Cannot determine Architecture from triple");
triple.split('-').nth(0).unwrap()
}

pub fn get_env(triple: &str) -> Option<&str> {
Expand Down

0 comments on commit 4ab843a

Please sign in to comment.