Skip to content

Commit

Permalink
Skip testing targets that don't ship libstd
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemo157 committed Dec 1, 2018
1 parent 8d2bc97 commit 6180d99
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,27 @@ fn is_target_dir<P: Into<PathBuf>>(path: P) -> bool {
path.metadata().map(|m| m.is_dir()).unwrap_or(false)
}

fn target_has_std<P: Into<PathBuf>>(path: P) -> bool {
let target_lib_dir = path.into().join("lib");
std::fs::read_dir(target_lib_dir)
.expect("invalid target")
.map(|entry| entry.unwrap())
.filter(|entry| entry.file_type().unwrap().is_file())
.filter_map(|entry| entry.file_name().into_string().ok())
.any(|file_name| file_name.starts_with("libstd") && file_name.ends_with(".rlib"))
}


fn for_all_targets<F: FnMut(String)>(sysroot: &Path, mut f: F) {
let target_dir = sysroot.join("lib").join("rustlib");
for entry in std::fs::read_dir(target_dir).expect("invalid sysroot") {
let entry = entry.unwrap();
if !is_target_dir(entry.path()) {
continue;
}
if !target_has_std(entry.path()) {
continue;
}
let target = entry.file_name().into_string().unwrap();
f(target);
}
Expand Down

0 comments on commit 6180d99

Please sign in to comment.