Skip to content

Commit d9ad596

Browse files
rbro112Claude Sonnet 4
andcommitted
test(ci): Update compute-sentry-selected-tests for ALWAYS_RUN_TESTS
ALWAYS_RUN_TESTS is now appended to every selective run, causing tests that checked exact counts and output files to fail (expected N, got N+1). Import ALWAYS_RUN_TESTS and update assertions to account for it: - test-count assertions use len(ALWAYS_RUN_TESTS) as a base offset - output file assertions compare against the expected set including ALWAYS_RUN_TESTS, validating that those tests are always appended Co-Authored-By: Claude Sonnet 4 <noreply@example.com>
1 parent 9d97ed3 commit d9ad596

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

.github/workflows/scripts/test_compute_sentry_selected_tests.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
sys.modules["compute_sentry_selected_tests"] = _mod
2020
_spec.loader.exec_module(_mod)
2121

22-
from compute_sentry_selected_tests import _query_coverage, main
22+
from compute_sentry_selected_tests import ALWAYS_RUN_TESTS, _query_coverage, main
2323

2424

2525
def _create_coverage_db(path: str, file_to_contexts: dict[str, list[str]]) -> None:
@@ -178,8 +178,9 @@ def test_selective_returns_matched_tests(self, tmp_path):
178178

179179
gh = gh_output.read_text()
180180
assert "has-selected-tests=true" in gh
181-
assert "test-count=1" in gh
182-
assert output.read_text().strip() == "tests/sentry/test_org.py"
181+
assert f"test-count={1 + len(ALWAYS_RUN_TESTS)}" in gh
182+
expected_output = sorted({"tests/sentry/test_org.py"} | ALWAYS_RUN_TESTS)
183+
assert output.read_text().splitlines() == expected_output
183184

184185
def test_getsentry_tests_filtered_out(self, tmp_path):
185186
"""Coverage may return getsentry tests — they should be filtered."""
@@ -211,8 +212,9 @@ def test_getsentry_tests_filtered_out(self, tmp_path):
211212
{"GITHUB_OUTPUT": str(gh_output)},
212213
)
213214

214-
assert "test-count=1" in gh_output.read_text()
215-
assert output.read_text().strip() == "tests/sentry/test_org.py"
215+
assert f"test-count={1 + len(ALWAYS_RUN_TESTS)}" in gh_output.read_text()
216+
expected_output = sorted({"tests/sentry/test_org.py"} | ALWAYS_RUN_TESTS)
217+
assert output.read_text().splitlines() == expected_output
216218

217219
def test_changed_test_file_included(self, tmp_path):
218220
db_path = tmp_path / "coverage.db"
@@ -236,7 +238,7 @@ def test_changed_test_file_included(self, tmp_path):
236238

237239
gh = gh_output.read_text()
238240
assert "has-selected-tests=true" in gh
239-
assert "test-count=1" in gh
241+
assert f"test-count={1 + len(ALWAYS_RUN_TESTS)}" in gh
240242

241243
def test_excluded_test_dirs_skipped(self, tmp_path):
242244
"""Tests in acceptance/apidocs/js/tools should not be selected."""
@@ -257,7 +259,7 @@ def test_excluded_test_dirs_skipped(self, tmp_path):
257259
{"GITHUB_OUTPUT": str(gh_output)},
258260
)
259261

260-
assert "test-count=0" in gh_output.read_text()
262+
assert f"test-count={len(ALWAYS_RUN_TESTS)}" in gh_output.read_text()
261263

262264
def test_zero_tests_signals_selective_applied(self, tmp_path):
263265
"""0 tests after filtering should signal 'run nothing', not full suite."""
@@ -282,8 +284,8 @@ def test_zero_tests_signals_selective_applied(self, tmp_path):
282284

283285
gh = gh_output.read_text()
284286
assert "has-selected-tests=true" in gh
285-
assert "test-count=0" in gh
286-
assert output.read_text() == ""
287+
assert f"test-count={len(ALWAYS_RUN_TESTS)}" in gh
288+
assert set(output.read_text().splitlines()) == ALWAYS_RUN_TESTS
287289

288290
def test_renamed_file_queries_old_path(self, tmp_path):
289291
"""When a file is renamed, the old path should be queried against the coverage DB."""
@@ -319,8 +321,9 @@ def test_renamed_file_queries_old_path(self, tmp_path):
319321

320322
gh = gh_output.read_text()
321323
assert "has-selected-tests=true" in gh
322-
assert "test-count=1" in gh
323-
assert output.read_text().strip() == "tests/sentry/test_old_name.py"
324+
assert f"test-count={1 + len(ALWAYS_RUN_TESTS)}" in gh
325+
expected_output = sorted({"tests/sentry/test_old_name.py"} | ALWAYS_RUN_TESTS)
326+
assert output.read_text().splitlines() == expected_output
324327

325328
def test_renamed_file_without_previous_misses_coverage(self, tmp_path):
326329
"""Without --previous-filenames, a renamed file gets no coverage hits."""
@@ -349,7 +352,7 @@ def test_renamed_file_without_previous_misses_coverage(self, tmp_path):
349352

350353
gh = gh_output.read_text()
351354
assert "has-selected-tests=true" in gh
352-
assert "test-count=0" in gh
355+
assert f"test-count={len(ALWAYS_RUN_TESTS)}" in gh
353356

354357
def test_missing_db_returns_error(self):
355358
ret = _run(["--coverage-db", "/nonexistent/coverage.db", "--changed-files", "foo.py"])

0 commit comments

Comments
 (0)