Skip to content

Commit 0e0375c

Browse files
committed
roachtest: add test for selective tests
Add a test for selective tests to ensure that all skipped tests are logged in the output. Epic: None Release note: None
1 parent d66a92d commit 0e0375c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

pkg/cmd/roachtest/main_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package main
77

88
import (
9+
"bytes"
910
"context"
1011
gosql "database/sql"
1112
"fmt"
@@ -483,3 +484,27 @@ func shuffleStrings(r *rand.Rand, strings []string) []string {
483484
})
484485
return strings
485486
}
487+
488+
func TestSkippedSelectSpecs(t *testing.T) {
489+
specs := []registry.TestSpec{}
490+
for i := range 5 {
491+
specs = append(specs, registry.TestSpec{Name: fmt.Sprintf("t%d", i+1)})
492+
}
493+
494+
rng := randutil.NewTestRandWithSeed(0)
495+
buf := bytes.NewBuffer(nil)
496+
_ = selectSpecs(specs, rng, 0.1, false, buf)
497+
498+
containsTestSkip := func(testName string) bool {
499+
return strings.Contains(buf.String(), fmt.Sprintf("--- SKIP: %s", testName))
500+
}
501+
502+
// With the fixed random seed above, these are the expected skipped tests.
503+
expectedSkippedTests := []string{"t1", "t2", "t3", "t5"}
504+
for _, testName := range expectedSkippedTests {
505+
assert.True(t, containsTestSkip(testName), "Expected skip message for %s not found in buffer", testName)
506+
}
507+
// With the fixed random seed above, the test t4 should not be skipped.
508+
testName := "t4"
509+
assert.False(t, containsTestSkip(testName), "Expected no skip message for %s but found in buffer", testName)
510+
}

0 commit comments

Comments
 (0)