Skip to content

Commit c9cf556

Browse files
authored
Skip dummy subtest when EnvMatrix expands to empty (#4893)
## Changes When all EnvMatrix values are empty lists (e.g., `DATABRICKS_BUNDLE_ENGINE = []`), run the test directly without creating a `#00` dummy subtest. Before: ``` --- PASS: TestAccept/bundle/foo (0.00s) --- PASS: TestAccept/bundle/foo/#00 (1.23s) ``` After: ``` --- PASS: TestAccept/bundle/foo (1.23s) ``` This allows tests to opt out of the default engine matrix by setting `DATABRICKS_BUNDLE_ENGINE = []` without creating a confusingly-named subtest. ## Tests Added selftests: - `selftest/envmatrix_empty` — verifies no subtest is created when all EnvMatrix values are empty - `selftest/envmatrix_mixed` — verifies empty vars are dropped while non-empty vars still create subtests
1 parent 6988c16 commit c9cf556

File tree

9 files changed

+40
-8
lines changed

9 files changed

+40
-8
lines changed

acceptance/acceptance_test.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -416,14 +416,20 @@ func testAccept(t *testing.T, inprocessMode bool, singleTest string) int {
416416
expanded = internal.SubsetExpanded(expanded, dir, scriptUsesEngine)
417417
}
418418

419-
for ind, envset := range expanded {
420-
envname := strings.Join(envset, "/")
421-
t.Run(envname, func(t *testing.T) {
422-
if runParallel {
423-
t.Parallel()
424-
}
425-
runTest(t, dir, ind, coverDir, repls.Clone(), config, envset, envFilters)
426-
})
419+
// If the matrix expands to a single empty envset, run the test directly
420+
// without creating a subtest (avoids the "#00" dummy subtest name).
421+
if len(expanded) == 1 && len(expanded[0]) == 0 {
422+
runTest(t, dir, 0, coverDir, repls.Clone(), config, nil, envFilters)
423+
} else {
424+
for ind, envset := range expanded {
425+
envname := strings.Join(envset, "/")
426+
t.Run(envname, func(t *testing.T) {
427+
if runParallel {
428+
t.Parallel()
429+
}
430+
runTest(t, dir, ind, coverDir, repls.Clone(), config, envset, envFilters)
431+
})
432+
}
427433
}
428434
})
429435
}

acceptance/selftest/envmatrix_empty/out.test.toml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
echo hello
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Local = true
2+
3+
[EnvMatrix]
4+
DATABRICKS_BUNDLE_ENGINE = []

acceptance/selftest/envmatrix_mixed/out.test.toml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FIRST=[FIRST]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
echo "FIRST=$FIRST"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Local = true
2+
3+
[EnvMatrix]
4+
DATABRICKS_BUNDLE_ENGINE = []
5+
FIRST = ["alpha", "beta"]
6+
SECOND = []

0 commit comments

Comments
 (0)