| 30 | } |
| 31 | |
| 32 | func RunTestscripts(t *testing.T, testscriptsDir string) { |
| 33 | globPattern := filepath.Join(testscriptsDir, "**/*.test.txt") |
| 34 | scripts := globScripts(globPattern) |
| 35 | require.NotEmpty(t, scripts, "no test scripts found") |
| 36 | |
| 37 | shard := shardFromEnv(t) |
| 38 | |
| 39 | // Run each test script (a file ending in .test.txt) in its own |
| 40 | // testscript.Run call so that we can shard at the granularity of an |
| 41 | // individual script. The scripts still run as parallel subtests. |
| 42 | for i, script := range scripts { |
| 43 | if !shard.includes(i) { |
| 44 | continue |
| 45 | } |
| 46 | params := getTestscriptParams(filepath.Dir(script)) |
| 47 | // Pass the single script explicitly rather than its directory so that |
| 48 | // sharding partitions scripts, not whole directories. |
| 49 | params.Dir = "" |
| 50 | params.Files = []string{script} |
| 51 | testscript.Run(t, params) |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | // globScripts returns the test script files matching pattern, sorted for a |
| 56 | // deterministic order (so sharding is stable across runners). The testrunner |