|
12 | 12 | import subprocess as sp
|
13 | 13 | import sys
|
14 | 14 | from dataclasses import dataclass
|
15 |
| -from glob import glob, iglob |
| 15 | +from glob import glob |
16 | 16 | from pathlib import Path
|
17 | 17 | from typing import Any, Callable, TypeAlias
|
18 | 18 |
|
19 | 19 | SELF_PATH = Path(__file__)
|
20 | 20 | ETC_DIR = SELF_PATH.parent
|
21 | 21 | ROOT_DIR = ETC_DIR.parent
|
22 | 22 |
|
23 |
| -# Loose approximation of what gets checked in to git, without needing `git ls-files`. |
24 |
| -DIRECTORIES = [".github", "ci", "crates", "etc", "src"] |
25 |
| - |
26 | 23 | # These files do not trigger a retest.
|
27 | 24 | IGNORED_SOURCES = ["src/libm_helper.rs", "src/math/support/float_traits.rs"]
|
28 | 25 |
|
@@ -190,30 +187,31 @@ def tidy_lists(self) -> None:
|
190 | 187 | """In each file, check annotations indicating blocks of code should be sorted or should
|
191 | 188 | include all public API.
|
192 | 189 | """
|
193 |
| - for dirname in DIRECTORIES: |
194 |
| - dir = ROOT_DIR.joinpath(dirname) |
195 |
| - for fname in iglob("**", root_dir=dir, recursive=True): |
196 |
| - fpath = dir.joinpath(fname) |
197 |
| - if fpath.is_dir() or fpath == SELF_PATH: |
198 |
| - continue |
199 |
| - |
200 |
| - lines = fpath.read_text().splitlines() |
201 |
| - |
202 |
| - validate_delimited_block( |
203 |
| - fpath, |
204 |
| - lines, |
205 |
| - "verify-sorted-start", |
206 |
| - "verify-sorted-end", |
207 |
| - ensure_sorted, |
208 |
| - ) |
209 |
| - |
210 |
| - validate_delimited_block( |
211 |
| - fpath, |
212 |
| - lines, |
213 |
| - "verify-apilist-start", |
214 |
| - "verify-apilist-end", |
215 |
| - lambda p, n, lines: self.ensure_contains_api(p, n, lines), |
216 |
| - ) |
| 190 | + |
| 191 | + flist = sp.check_output(["git", "ls-files"], cwd=ROOT_DIR, text=True) |
| 192 | + |
| 193 | + for path in flist.splitlines(): |
| 194 | + fpath = ROOT_DIR.joinpath(path) |
| 195 | + if fpath.is_dir() or fpath == SELF_PATH: |
| 196 | + continue |
| 197 | + |
| 198 | + lines = fpath.read_text().splitlines() |
| 199 | + |
| 200 | + validate_delimited_block( |
| 201 | + fpath, |
| 202 | + lines, |
| 203 | + "verify-sorted-start", |
| 204 | + "verify-sorted-end", |
| 205 | + ensure_sorted, |
| 206 | + ) |
| 207 | + |
| 208 | + validate_delimited_block( |
| 209 | + fpath, |
| 210 | + lines, |
| 211 | + "verify-apilist-start", |
| 212 | + "verify-apilist-end", |
| 213 | + lambda p, n, lines: self.ensure_contains_api(p, n, lines), |
| 214 | + ) |
217 | 215 |
|
218 | 216 | def ensure_contains_api(self, fpath: Path, line_num: int, lines: list[str]):
|
219 | 217 | """Given a list of strings, ensure that each public function we have is named
|
|
0 commit comments