Skip to content

Commit 0ca1dca

Browse files
authored
Create TEST_SHARD_STATUS_FILE when sharding tests (#3547)
Bazel claims to check that this file has been touched when sharding tests. It currently doesn't, but that will change soon.
1 parent 2a71311 commit 0ca1dca

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

go/tools/builders/generate_test_main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ func testsInShard() []testing.InternalTest {
146146
if err != nil || totalShards <= 1 {
147147
return allTests
148148
}
149+
file, err := os.Create(os.Getenv("TEST_SHARD_STATUS_FILE"))
150+
if err != nil {
151+
log.Fatalf("Failed to touch TEST_SHARD_STATUS_FILE: %v", err)
152+
}
153+
_ = file.Close()
149154
shardIndex, err := strconv.Atoi(os.Getenv("TEST_SHARD_INDEX"))
150155
if err != nil || shardIndex < 0 {
151156
return allTests

tests/core/go_test/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,12 @@ go_test(
244244
],
245245
)
246246

247+
go_test(
248+
name = "sharding_test",
249+
srcs = ["sharding_test.go"],
250+
shard_count = 2,
251+
)
252+
247253
go_bazel_test(
248254
name = "env_inherit_test",
249255
srcs = ["env_inherit_test.go"],
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package sharding_test
2+
3+
import (
4+
"log"
5+
"os"
6+
"testing"
7+
)
8+
9+
func TestShardStatusFile(t *testing.T) {
10+
if _, err := os.Stat(os.Getenv("TEST_SHARD_STATUS_FILE")); err != nil {
11+
log.Fatalf("Expected Go test runner to create TEST_SHARD_STATUS_FILE: %v", err)
12+
}
13+
}

0 commit comments

Comments
 (0)