Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 0575358

Browse files
committed
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 fd7ad36)
1 parent e299027 commit 0575358

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

crates/libm-test/build.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,11 @@ mod musl_serialized_tests {
156156
return;
157157
}
158158

159-
let files = fs::read_dir(math_src).unwrap().map(|f| f.unwrap().path()).collect::<Vec<_>>();
159+
let files = fs::read_dir(math_src)
160+
.unwrap()
161+
.map(|f| f.unwrap().path())
162+
.filter(file_needs_test)
163+
.collect::<Vec<_>>();
160164

161165
let mut math = Vec::new();
162166
for file in files {
@@ -187,6 +191,19 @@ mod musl_serialized_tests {
187191
generate_unit_tests(&math);
188192
}
189193

194+
/// Check whether a path within `src/math` should get tests generated.
195+
fn file_needs_test(path: &PathBuf) -> bool {
196+
// Skip directories
197+
if path.is_dir() {
198+
return false;
199+
}
200+
201+
let fname = path.file_name().unwrap().to_str().unwrap();
202+
203+
// Musl doesn't support `f16` or `f128`
204+
!(fname.contains("f16") || fname.contains("f128"))
205+
}
206+
190207
/// A "poor man's" parser for the signature of a function
191208
fn parse(s: &str) -> Function {
192209
let s = eat(s, "pub fn ");

0 commit comments

Comments
 (0)