Skip to content

Commit 064b824

Browse files
authored
Merge pull request #3048 from dolthub/angela/keyless_subquery
Added field to ScriptTest to skip test
2 parents 2ed3ee0 + 8bf77f0 commit 064b824

File tree

2 files changed

+18
-27
lines changed

2 files changed

+18
-27
lines changed

enginetest/evaluation.go

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,8 @@ func TestScriptWithEngine(t *testing.T, e QueryEngine, harness Harness, script q
8484
require.NoError(t, err, nil)
8585

8686
t.Run(script.Name, func(t *testing.T) {
87-
if sh, ok := harness.(SkippingHarness); ok {
88-
if sh.SkipQueryTest(script.Name) {
89-
t.Skip()
90-
}
91-
92-
if !supportedDialect(harness, script.Dialect) {
93-
t.Skip()
94-
}
87+
if skipScript(harness, script, false) {
88+
t.Skip()
9589
}
9690

9791
for _, statement := range script.SetUpScript {
@@ -126,7 +120,7 @@ func TestScriptWithEngine(t *testing.T, e QueryEngine, harness Harness, script q
126120
ctx = th.NewSession()
127121
}
128122

129-
if skipAssertion(t, harness, assertion) {
123+
if skipAssertion(harness, assertion) {
130124
t.Skip()
131125
}
132126

@@ -161,30 +155,26 @@ func TestScriptWithEngine(t *testing.T, e QueryEngine, harness Harness, script q
161155
})
162156
}
163157

164-
func skipAssertion(t *testing.T, harness Harness, assertion queries.ScriptTestAssertion) bool {
165-
if sh, ok := harness.(SkippingHarness); ok && sh.SkipQueryTest(assertion.Query) {
158+
func skipScript(harness Harness, script queries.ScriptTest, prepared bool) bool {
159+
if sh, ok := harness.(SkippingHarness); ok && sh.SkipQueryTest(script.Name) {
166160
return true
167161
}
168162

169-
if !supportedDialect(harness, assertion.Dialect) {
170-
return true
171-
}
163+
return script.Skip || !supportedDialect(harness, script.Dialect) || (prepared && script.SkipPrepared)
164+
}
172165

173-
if assertion.Skip {
166+
func skipAssertion(harness Harness, assertion queries.ScriptTestAssertion) bool {
167+
if sh, ok := harness.(SkippingHarness); ok && sh.SkipQueryTest(assertion.Query) {
174168
return true
175169
}
176170

177-
return false
171+
return assertion.Skip || !supportedDialect(harness, assertion.Dialect)
178172
}
179173

180174
// TestScriptPrepared substitutes literals for bindvars, runs the test script given,
181175
// and makes any assertions given
182176
func TestScriptPrepared(t *testing.T, harness Harness, script queries.ScriptTest) bool {
183177
return t.Run(script.Name, func(t *testing.T) {
184-
if script.SkipPrepared {
185-
t.Skip()
186-
}
187-
188178
e := mustNewEngine(t, harness)
189179
defer e.Close()
190180
TestScriptWithEnginePrepared(t, e, harness, script)
@@ -194,6 +184,10 @@ func TestScriptPrepared(t *testing.T, harness Harness, script queries.ScriptTest
194184
// TestScriptWithEnginePrepared runs the test script with bindvars substituted for literals
195185
// using the engine provided.
196186
func TestScriptWithEnginePrepared(t *testing.T, e QueryEngine, harness Harness, script queries.ScriptTest) {
187+
if skipScript(harness, script, true) {
188+
t.Skip()
189+
}
190+
197191
ctx := NewContext(harness)
198192
err := CreateNewConnectionForServerEngine(ctx, e)
199193
require.NoError(t, err, nil)
@@ -223,13 +217,7 @@ func TestScriptWithEnginePrepared(t *testing.T, e QueryEngine, harness Harness,
223217

224218
for _, assertion := range assertions {
225219
t.Run(assertion.Query, func(t *testing.T) {
226-
227-
if sh, ok := harness.(SkippingHarness); ok {
228-
if sh.SkipQueryTest(assertion.Query) {
229-
t.Skip()
230-
}
231-
}
232-
if assertion.Skip {
220+
if skipAssertion(harness, assertion) {
233221
t.Skip()
234222
}
235223

enginetest/queries/script_queries.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ type ScriptTest struct {
5252
// Dialect is the supported dialect for this script, which must match the dialect of the harness if specified.
5353
// The script is skipped if the dialect doesn't match.
5454
Dialect string
55+
// Skip is used to completely skip a test, not execute any part of the script, and to record it as a skipped test in
56+
// the test suite results.
57+
Skip bool
5558
}
5659

5760
type ScriptTestAssertion struct {

0 commit comments

Comments
 (0)