1919sys .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
2525def _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,10 +259,10 @@ 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
262- def test_zero_tests_signals_selective_applied (self , tmp_path ):
263- """0 tests after filtering should signal ' run nothing' , not full suite."""
264+ def test_zero_coverage_matches_still_runs_always_run_tests (self , tmp_path ):
265+ """No coverage matches should still run ALWAYS_RUN_TESTS , not the full suite."""
264266 db_path = tmp_path / "coverage.db"
265267 _create_coverage_db (str (db_path ), {})
266268 output = tmp_path / "output.txt"
@@ -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