diff --git a/.github/scripts/check-native-coverage.py b/.github/scripts/check-native-coverage.py index 6fe4dfd8..ce9354fc 100644 --- a/.github/scripts/check-native-coverage.py +++ b/.github/scripts/check-native-coverage.py @@ -186,7 +186,11 @@ def check_changed(lines, changed, minimum, compiled, platform="windows"): total += 1 covered += lines[name][line] > 0 if not total: - raise ValueError('no measured changed executable lines in workspace') + # Every changed line is non-executable (a constant table entry, a + # plain comment, an attribute): there is nothing to measure. Required + # platform sources were checked above, and every executable source + # still needs LCOV, so this cannot hide missing instrumentation. + return None if covered * 100 < minimum * total: raise ValueError(f'changed lines: {covered}/{total} below {minimum}%') return covered, total diff --git a/.github/scripts/check-native-coverage_tests.py b/.github/scripts/check-native-coverage_tests.py index 883271b4..2c107afe 100644 --- a/.github/scripts/check-native-coverage_tests.py +++ b/.github/scripts/check-native-coverage_tests.py @@ -184,6 +184,15 @@ def test_low_changed_line_coverage_is_rejected(self): with self.assertRaisesRegex(ValueError, 'below 80'): gate.check_changed({WINDOWS: {3: 0}, ACL: {4: 1}}, {WINDOWS: {3}, ACL: {4}}, 80, COMPILED) + def test_changes_with_no_executable_line_skip_only_changed_line_gate(self): + # Line 9 of the adapter is a changed constant entry with no LCOV line. + compiled = {**COMPILED, ADAPTER: (4, 4)} + lines = {WINDOWS: {3: 1}, ACL: {4: 1}, ADAPTER: {10: 1}} + self.assertIsNone(gate.check_changed(lines, {ADAPTER: {9}}, 80, compiled)) + # The inventory checks still run first: an uninstrumented source fails. + with self.assertRaisesRegex(ValueError, 'missing executable LCOV source'): + gate.check_changed({WINDOWS: {3: 1}, ACL: {4: 1}}, {ADAPTER: {9}}, 80, compiled) + def test_no_production_changes_skip_only_changed_line_gate(self): self.assertIsNone(gate.check_changed({WINDOWS: {3: 1}, ACL: {4: 1}}, {}, 80, COMPILED)) self.assertEqual(gate.changed_lines('+++ b/crates/a/src/sink_tests.rs\n@@ -0,0 +1 @@\n+x\n'), {})