File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -97,3 +97,29 @@ func SkipFlakey(t *testing.T, ticketURL string) {
9797 t .Skip ("Flakey" , ticketURL )
9898 }
9999}
100+
101+ const envVarTestSuite = "CL_CURRENT_TEST_SUITE"
102+
103+ // BelongsToCISuite declares the test's suite, and only runs the tests if the environment is configured
104+ // to run the given suite. Usage inside a test:
105+ //
106+ // func TestFoo(t *testing.T) {
107+ // testutil.BelongsToCISuite(t, "integration")
108+ // ...
109+ // }
110+ //
111+ // If CL_CURRENT_TEST_SUITE is not set, all tests are run.
112+ // If CL_CURRENT_TEST_SUITE is set, only tests belonging to that suite are run; others are skipped.
113+ //
114+ // In general - this allows CI pipelines to run more targeted tests, to speed up feedback loops.
115+ func BelongsToCISuite (t * testing.T , suite string ) {
116+ t .Helper ()
117+
118+ envSuite := os .Getenv (envVarTestSuite )
119+ if envSuite == "" {
120+ return
121+ }
122+ if envSuite != suite {
123+ t .Skipf ("Skipping test: suite %q does not match %s=%q" , suite , envVarTestSuite , envSuite )
124+ }
125+ }
You can’t perform that action at this time.
0 commit comments