Update libm-test/build.rs to skip directories

Don't try to generate tests for directories, or for files that contain
`f16` or `f128` (as these types are not provided by musl's math
implementations).

(cherry picked from commit fd7ad36b70d0bbc0f0b9bc7e54d10258423fda29)
This commit is contained in:
Trevor Gross 2024-10-26 03:05:01 -05:00
parent 395419d2d2
commit ad1c652293

View file

@ -156,7 +156,11 @@ mod musl_serialized_tests {
return;
}
let files = fs::read_dir(math_src).unwrap().map(|f| f.unwrap().path()).collect::<Vec<_>>();
let files = fs::read_dir(math_src)
.unwrap()
.map(|f| f.unwrap().path())
.filter(file_needs_test)
.collect::<Vec<_>>();
let mut math = Vec::new();
for file in files {
@ -187,6 +191,19 @@ mod musl_serialized_tests {
generate_unit_tests(&math);
}
/// Check whether a path within `src/math` should get tests generated.
fn file_needs_test(path: &PathBuf) -> bool {
// Skip directories
if path.is_dir() {
return false;
}
let fname = path.file_name().unwrap().to_str().unwrap();
// Musl doesn't support `f16` or `f128`
!(fname.contains("f16") || fname.contains("f128"))
}
/// A "poor man's" parser for the signature of a function
fn parse(s: &str) -> Function {
let s = eat(s, "pub fn ");