Skip to content

Commit 6204a0a

Browse files
committed
internal/cuetxtar: support matrix name skips like #skip-v2
cue/testdata/readme.md suggests that #skip-{name} options are supported as well as a global #skip at the top of a testscript. Indeed #skip works just fine, but for example #skip-v2 does not, because it is simply not implemented in cuetxtar itself. Implement generic support for #skip-{name} in cuetxtar when running via a test matrix. This allows removing the same implementations from encoding/openapi and tools/trim, as they can rely on cuetxtar now. internal/core/adt is slightly different; it uses top-level TestEvalV2 and TestEvalV3 tests rather than a test matrix. Don't refactor that right now as it would cause lots of churn, but instead add a workaround to support #skip-v2 for TestEvalV2, which is necessary for regression tests where evalv2 panics or hangs. Leave a TODO as a reminder to clean this up in the future. For #2526. Signed-off-by: Daniel Martí <[email protected]> Change-Id: Ia4b3aa5b95dc1924ffe6db417f67e89b09469941 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1214545 TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Matthew Sackman <[email protected]>
1 parent 2aee339 commit 6204a0a

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

encoding/openapi/openapi_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ func TestGenerateOpenAPI(t *testing.T) {
6868
}
6969

7070
test.Run(t, func(t *cuetxtar.Test) {
71-
if t.HasTag("skip-" + t.Name()) {
72-
t.Skip()
73-
}
74-
7571
a := t.Instance()
7672
ctx := t.CueContext()
7773
v := ctx.BuildInstance(a)

internal/cuetxtar/txtar.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ type TxTarTest struct {
9898
// A txtar file can define test-specific tags and values in the comment section.
9999
// These are available via the [Test.HasTag] and [Test.Value] methods.
100100
// The #skip tag causes a [Test] to be skipped.
101+
// When running via [cuetdtest.Matrix], #skip-[cuetdtest.M.Name] tags can also be used.
101102
// The #noformat tag causes the $CUE_FORMAT_TXTAR value
102103
// to be ignored.
103104
//
@@ -459,7 +460,16 @@ func (x *TxTarTest) run(t *testing.T, m *cuetdtest.M, f func(tc *Test)) {
459460
if tc.HasTag("skip") {
460461
t.Skip()
461462
}
462-
463+
if tc.M != nil {
464+
// When running via [cuetdtest.Matrix], support e.g. #skip-v2.
465+
if tc.HasTag("skip-" + tc.Name()) {
466+
t.Skip()
467+
}
468+
} else if tc.HasTag("skip-v2") && strings.Contains(t.Name(), "EvalV2") {
469+
// Temporary hack since internal/core/adt uses TestEvalV2 rather than [cuetdtest.Matrix].
470+
// TODO(mvdan): clean this up.
471+
t.Skip()
472+
}
463473
if msg, ok := x.Skip[testName]; ok {
464474
t.Skip(msg)
465475
}

tools/trim/trim_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ func TestTrimFiles(t *testing.T) {
4040
}
4141

4242
test.Run(t, func(t *cuetxtar.Test) {
43-
if t.HasTag("skip-" + t.Name()) {
44-
t.Skip()
45-
}
4643
a := t.Instance()
4744
ctx := t.CueContext()
4845
val := ctx.BuildInstance(a)

0 commit comments

Comments
 (0)