Test that IWYU is available via check_iwyu_available()
(self)
| 16 | """Test IWYU integration in the FastLED project""" |
| 17 | |
| 18 | def test_iwyu_availability(self): |
| 19 | """Test that IWYU is available via check_iwyu_available()""" |
| 20 | # Import the function from ci-iwyu by loading the module directly |
| 21 | import importlib.util |
| 22 | |
| 23 | ci_iwyu_path = Path(__file__).parent / "ci-iwyu.py" |
| 24 | spec = importlib.util.spec_from_file_location("ci_iwyu", ci_iwyu_path) |
| 25 | if spec is None or spec.loader is None: |
| 26 | self.fail("Failed to load ci-iwyu.py module") |
| 27 | return |
| 28 | |
| 29 | ci_iwyu = importlib.util.module_from_spec(spec) |
| 30 | spec.loader.exec_module(ci_iwyu) |
| 31 | |
| 32 | is_available, prefix = ci_iwyu.check_iwyu_available() |
| 33 | |
| 34 | # Assert that IWYU is available (either system or clang-tool-chain) |
| 35 | self.assertTrue( |
| 36 | is_available, |
| 37 | "IWYU should be available either as system command or via clang-tool-chain", |
| 38 | ) |
| 39 | |
| 40 | # Check that prefix is valid (empty string or "uv run ") |
| 41 | self.assertIn(prefix, ["", "uv run "], f"Unexpected IWYU prefix: '{prefix}'") |
| 42 | |
| 43 | print(f"✅ IWYU is available with prefix: '{prefix}'") |
| 44 | |
| 45 | def test_ci_iwyu_script_exists(self): |
| 46 | """Test that the ci-iwyu.py script exists""" |