Searches through the program files to check for banned headers, excluding src/platforms.
(self)
| 37 | return failings |
| 38 | |
| 39 | def test_no_bad_defines(self) -> None: |
| 40 | """Searches through the program files to check for banned headers, excluding src/platforms.""" |
| 41 | files_to_check: list[str] = [] |
| 42 | for root, _, files in os.walk(SRC_ROOT): |
| 43 | for file in files: |
| 44 | if file.endswith( |
| 45 | (".cpp", ".h", ".hpp") |
| 46 | ): # Add or remove file extensions as needed |
| 47 | file_path = os.path.join(root, file) |
| 48 | files_to_check.append(file_path) |
| 49 | |
| 50 | all_failings: list[str] = [] |
| 51 | with ThreadPoolExecutor(max_workers=NUM_WORKERS) as executor: |
| 52 | futures = [ |
| 53 | executor.submit(self.check_file, file_path) |
| 54 | for file_path in files_to_check |
| 55 | ] |
| 56 | for future in futures: |
| 57 | all_failings.extend(future.result()) |
| 58 | |
| 59 | if all_failings: |
| 60 | msg = f"Found {len(all_failings)} bad defines: \n" + "\n".join(all_failings) |
| 61 | for failing in all_failings: |
| 62 | print(failing) |
| 63 | self.fail("Please fix the defines: \n" + msg + "\n") |
| 64 | else: |
| 65 | print("No bad defines found.") |
| 66 | |
| 67 | |
| 68 | if __name__ == "__main__": |