Enable shards in runtime test runner.

Fixed an issue with the runtime test runner which enables us to run tests in
shards. We had to touch the status file as indicated by an env var.

PiperOrigin-RevId: 320236205
This commit is contained in:
Ayush Ranjan
2020-07-08 12:05:04 -07:00
committed by gVisor bot
parent efa2615eb0
commit e3db9bda60
2 changed files with 20 additions and 0 deletions
+15
View File
@@ -482,6 +482,21 @@ func IsStatic(filename string) (bool, error) {
return true, nil
}
// TouchShardStatusFile indicates to Bazel that the test runner supports
// sharding by creating or updating the last modified date of the file
// specified by TEST_SHARD_STATUS_FILE.
//
// See https://docs.bazel.build/versions/master/test-encyclopedia.html#role-of-the-test-runner.
func TouchShardStatusFile() error {
if statusFile := os.Getenv("TEST_SHARD_STATUS_FILE"); statusFile != "" {
cmd := exec.Command("touch", statusFile)
if b, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("touch %q failed:\n output: %s\n error: %s", statusFile, string(b), err.Error())
}
}
return nil
}
// TestIndicesForShard returns indices for this test shard based on the
// TEST_SHARD_INDEX and TEST_TOTAL_SHARDS environment vars.
//
+5
View File
@@ -63,6 +63,11 @@ func runTests() int {
d := dockerutil.MakeDocker(testutil.DefaultLogger(*lang))
defer d.CleanUp()
if err := testutil.TouchShardStatusFile(); err != nil {
fmt.Fprintf(os.Stderr, "error touching status shard file: %v\n", err)
return 1
}
// Get a slice of tests to run. This will also start a single Docker
// container that will be used to run each test. The final test will
// stop the Docker container.