Skip to content

Commit 905a7d0

Browse files
committed
Add option to run single conformance test for test dev/debug
1 parent 18506b7 commit 905a7d0

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

conformance/conformance_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ func TestConformance(t *testing.T) {
7373
NamespaceLabels: namespaceLabels,
7474
NamespaceAnnotations: namespaceAnnotations,
7575
SkipTests: skipTests,
76+
RunTest: *flags.RunTest,
7677
})
7778
cSuite.Setup(t)
7879

conformance/utils/flags/flags.go

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var (
2929
CleanupBaseResources = flag.Bool("cleanup-base-resources", true, "Whether to cleanup base test resources after the run")
3030
SupportedFeatures = flag.String("supported-features", "", "Supported features included in conformance tests suites")
3131
SkipTests = flag.String("skip-tests", "", "Comma-separated list of tests to skip")
32+
RunTest = flag.String("run-test", "", "Name of a single tests to run, instead of the whole suite")
3233
ExemptFeatures = flag.String("exempt-features", "", "Exempt Features excluded from conformance tests suites")
3334
EnableAllSupportedFeatures = flag.Bool("all-features", false, "Whether to enable all supported features for conformance tests")
3435
NamespaceLabels = flag.String("namespace-labels", "", "Comma-separated list of name=value labels to add to test namespaces")

conformance/utils/suite/suite.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ type ConformanceTestSuite struct {
5050
SupportedFeatures sets.Set[SupportedFeature]
5151
TimeoutConfig config.TimeoutConfig
5252
SkipTests sets.Set[string]
53+
RunTest string
5354
FS embed.FS
5455
}
5556

@@ -76,6 +77,8 @@ type Options struct {
7677
// SkipTests contains all the tests not to be run and can be used to opt out
7778
// of specific tests
7879
SkipTests []string
80+
// RunTest is a single test to run, mostly for development/debugging convenience.
81+
RunTest string
7982

8083
FS *embed.FS
8184
}
@@ -125,6 +128,7 @@ func New(s Options) *ConformanceTestSuite {
125128
SupportedFeatures: s.SupportedFeatures,
126129
TimeoutConfig: s.TimeoutConfig,
127130
SkipTests: sets.New(s.SkipTests...),
131+
RunTest: s.RunTest,
128132
FS: *s.FS,
129133
}
130134

@@ -222,7 +226,7 @@ func (test *ConformanceTest) Run(t *testing.T, suite *ConformanceTestSuite) {
222226
}
223227

224228
// check that the test should not be skipped
225-
if suite.SkipTests.Has(test.ShortName) {
229+
if suite.SkipTests.Has(test.ShortName) || suite.RunTest != "" && suite.RunTest != test.ShortName {
226230
t.Skipf("Skipping %s: test explicitly skipped", test.ShortName)
227231
}
228232

0 commit comments

Comments
 (0)