Skip to content

Commit 0e3b1e3

Browse files
committed
acceptance: apply sharding only to the full TestAccept run
TestInprocessMode calls testAccept with a specific singleTest ("selftest/basic"). The shard filter lived in getTests(), so it ran before singleTest selection and could strip the requested test out of the shard, failing with "did not match any tests" on every shard that didn't own selftest/basic. Move the shard filter into a shardTests helper applied in testAccept only when singleTest == "", leaving named-test selection unsharded. Co-authored-by: Isaac
1 parent 7397c34 commit 0e3b1e3

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

acceptance/acceptance_test.go

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@ func testAccept(t *testing.T, inprocessMode bool, singleTest string) int {
350350
return n != singleTest
351351
})
352352
require.NotEmpty(t, testDirs, "singleTest=%#v did not match any tests\n%#v", singleTest, testDirs)
353+
} else {
354+
// Sharding applies only to the full run. A specific singleTest (e.g.
355+
// TestInprocessMode) must never be filtered out by the shard split.
356+
testDirs = shardTests(testDirs)
353357
}
354358

355359
skippedDirs := 0
@@ -510,21 +514,25 @@ func getTests(t *testing.T) []string {
510514
require.NoError(t, err)
511515

512516
slices.Sort(testDirs)
517+
return testDirs
518+
}
513519

514-
// Shard the test list when SHARD_TOTAL > 1. Tests are sorted above so the
515-
// split is deterministic and stable across runs.
516-
if total, _ := strconv.Atoi(os.Getenv("SHARD_TOTAL")); total > 1 {
517-
index, _ := strconv.Atoi(os.Getenv("SHARD_INDEX"))
518-
sharded := testDirs[:0]
519-
for i, d := range testDirs {
520-
if i%total == index {
521-
sharded = append(sharded, d)
522-
}
520+
// shardTests returns the subset of testDirs assigned to this CI shard when
521+
// SHARD_TOTAL > 1, or testDirs unchanged otherwise. testDirs must be sorted so
522+
// the split is deterministic and stable across runs.
523+
func shardTests(testDirs []string) []string {
524+
total, _ := strconv.Atoi(os.Getenv("SHARD_TOTAL"))
525+
if total <= 1 {
526+
return testDirs
527+
}
528+
index, _ := strconv.Atoi(os.Getenv("SHARD_INDEX"))
529+
sharded := testDirs[:0]
530+
for i, d := range testDirs {
531+
if i%total == index {
532+
sharded = append(sharded, d)
523533
}
524-
testDirs = sharded
525534
}
526-
527-
return testDirs
535+
return sharded
528536
}
529537

530538
func validateTestPhase(phase int) error {

0 commit comments

Comments
 (0)