Run example-Serial checker standalone.
()
| 174 | |
| 175 | |
| 176 | def main() -> None: |
| 177 | """Run example-Serial checker standalone.""" |
| 178 | if len(sys.argv) > 1: |
| 179 | file_path = Path(sys.argv[1]).resolve() |
| 180 | if not file_path.exists(): |
| 181 | print(f"Error: File not found: {file_path}") |
| 182 | sys.exit(1) |
| 183 | |
| 184 | checker = ExampleSerialChecker() |
| 185 | processor = MultiCheckerFileProcessor() |
| 186 | processor.process_files_with_checkers([str(file_path)], [checker]) |
| 187 | |
| 188 | if checker.violations: |
| 189 | print( |
| 190 | f"❌ Found raw Serial.* calls in enforced examples " |
| 191 | f"({len(checker.violations)} file(s)):\n" |
| 192 | ) |
| 193 | for file_path_str, violation_list in checker.violations.items(): |
| 194 | rel_path = Path(file_path_str).relative_to(PROJECT_ROOT) |
| 195 | print(f"{rel_path}:") |
| 196 | for line_num, message in violation_list: |
| 197 | print(f" Line {line_num}: {message}") |
| 198 | sys.exit(1) |
| 199 | else: |
| 200 | print("✅ No raw Serial.* calls in enforced examples.") |
| 201 | sys.exit(0) |
| 202 | else: |
| 203 | checker = ExampleSerialChecker() |
| 204 | run_checker_standalone( |
| 205 | checker, |
| 206 | [str(EXAMPLES_ROOT)], |
| 207 | "Found raw Serial.* calls in enforced examples", |
| 208 | extensions=[".cpp", ".h", ".hpp", ".ino"], |
| 209 | ) |
| 210 | |
| 211 | |
| 212 | if __name__ == "__main__": |
no test coverage detected