Return max mtime of source files in root directory only (no recursion). Used to check shared test headers in tests/ root without scanning all subdirs. Much faster than max_file_mtime() for large directory trees. Args: root: Directory to scan (non-recursive). exts: Froze
(root: Path, exts: frozenset = CPP_EXTS)
| 89 | |
| 90 | |
| 91 | def max_file_mtime_flat(root: Path, exts: frozenset = CPP_EXTS) -> float: |
| 92 | """Return max mtime of source files in root directory only (no recursion). |
| 93 | |
| 94 | Used to check shared test headers in tests/ root without scanning all subdirs. |
| 95 | Much faster than max_file_mtime() for large directory trees. |
| 96 | |
| 97 | Args: |
| 98 | root: Directory to scan (non-recursive). |
| 99 | exts: Frozenset of file extensions to match (default: C++ extensions). |
| 100 | |
| 101 | Returns: |
| 102 | Maximum file mtime (float), or 0.0 if no files match. |
| 103 | """ |
| 104 | max_mtime = 0.0 |
| 105 | try: |
| 106 | with os.scandir(str(root)) as it: |
| 107 | for entry in it: |
| 108 | try: |
| 109 | if entry.is_file(follow_symlinks=False): |
| 110 | _, ext = os.path.splitext(entry.name) |
| 111 | if ext.lower() in exts: |
| 112 | mtime = entry.stat(follow_symlinks=False).st_mtime |
| 113 | max_mtime = max(max_mtime, mtime) |
| 114 | except OSError: |
| 115 | pass |
| 116 | except OSError: |
| 117 | pass |
| 118 | return max_mtime |
| 119 | |
| 120 | |
| 121 | def load_test_names(build_dir: Path) -> list: |