From 22e4bbb401346fb7cb314d085c733eab743de062 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Sun, 25 Oct 2026 09:40:44 -0700 Subject: [PATCH] Block a Cancelled Compile Leg and Confine Inline Matches to the Column --- .github/workflows/test-pull-request.yml | 8 ++++---- tests/compile_lint/test_lint.py | 8 ++++++++ tools/compile-lint/src/compile_lint/lint.py | 5 ++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-pull-request.yml b/.github/workflows/test-pull-request.yml index 134db23..97b870d 100644 --- a/.github/workflows/test-pull-request.yml +++ b/.github/workflows/test-pull-request.yml @@ -207,9 +207,9 @@ jobs: exit 1 fi # The compile job is skipped when the change gate says nothing it covers moved. - # Only a real failure blocks, a skip must still pass. - # The matrix aggregates to a single result, failure if any leg failed. - if [[ "${{ needs.template-compile-test.result }}" == "failure" ]]; then - echo "Job 'template-compile-test' failed; refusing to pass." + # A skip must still pass, and anything else short of success blocks, a cancelled leg included. + result="${{ needs.template-compile-test.result }}" + if [[ "$result" != "success" && "$result" != "skipped" ]]; then + echo "Job 'template-compile-test' did not succeed ($result); refusing to pass." exit 1 fi diff --git a/tests/compile_lint/test_lint.py b/tests/compile_lint/test_lint.py index d4a8952..c4e9e63 100644 --- a/tests/compile_lint/test_lint.py +++ b/tests/compile_lint/test_lint.py @@ -517,3 +517,11 @@ def test_an_args_entry_beside_a_substituted_format_still_matches(tmp_path: Path) set_main(build, directive(root, 9), ' ESP_LOGD("main", "kitchen %.1f", x2.5);') result = lint(root, build).run() assert [(f.path, f.line) for f in result.findings] == [("test/device.yaml", 28)] + + +def test_an_inlined_expression_owns_only_the_occurrence_at_the_column(tmp_path: Path) -> None: + root, build = write_build(tmp_path, "") + # The lambda's y * 2.5 is on the line, but the warning sits on the first call, q * 2.5. + set_main(build, directive(root, 9), " other(q * 2.5); call.set_level(y * 2.5);") + result = lint(root, build).run() + assert result.findings == [] diff --git a/tools/compile-lint/src/compile_lint/lint.py b/tools/compile-lint/src/compile_lint/lint.py index 792d7f4..5899d8f 100644 --- a/tools/compile-lint/src/compile_lint/lint.py +++ b/tools/compile-lint/src/compile_lint/lint.py @@ -665,10 +665,9 @@ def match_inline(self, diagnostic: Diagnostic, source: str) -> Iterator[Finding] for line, pattern, literal in inline_expressions(self.index.scalars(relative)): if literal and not format_pattern(literal).search(source): continue + # Only the occurrence holding the diagnostic's column owns it. spans = [m.span() for m in pattern.finditer(generated)] - if literal: - spans = [(a, b) for a, b in spans if a <= column < b] - if spans: + if any(a <= column < b for a, b in spans): yield Finding(relative, line, 1, diagnostic.severity, diagnostic.message)