Skip to content

Commit 85d666f

Browse files
committed
created skipScript helper function and updated skipAssertion helper function
1 parent b527978 commit 85d666f

File tree

1 file changed

+15
-31
lines changed

1 file changed

+15
-31
lines changed

enginetest/evaluation.go

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +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 script.Skip {
89-
t.Skip()
90-
}
91-
92-
if sh.SkipQueryTest(script.Name) {
93-
t.Skip()
94-
}
95-
96-
if !supportedDialect(harness, script.Dialect) {
97-
t.Skip()
98-
}
87+
if skipScript(harness, script, false) {
88+
t.Skip()
9989
}
10090

10191
for _, statement := range script.SetUpScript {
@@ -130,7 +120,7 @@ func TestScriptWithEngine(t *testing.T, e QueryEngine, harness Harness, script q
130120
ctx = th.NewSession()
131121
}
132122

133-
if skipAssertion(t, harness, assertion) {
123+
if skipAssertion(harness, assertion) {
134124
t.Skip()
135125
}
136126

@@ -165,30 +155,26 @@ func TestScriptWithEngine(t *testing.T, e QueryEngine, harness Harness, script q
165155
})
166156
}
167157

168-
func skipAssertion(t *testing.T, harness Harness, assertion queries.ScriptTestAssertion) bool {
169-
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) {
170160
return true
171161
}
172162

173-
if !supportedDialect(harness, assertion.Dialect) {
174-
return true
175-
}
163+
return script.Skip || !supportedDialect(harness, script.Dialect) || (prepared && script.SkipPrepared)
164+
}
176165

177-
if assertion.Skip {
166+
func skipAssertion(harness Harness, assertion queries.ScriptTestAssertion) bool {
167+
if sh, ok := harness.(SkippingHarness); ok && sh.SkipQueryTest(assertion.Query) {
178168
return true
179169
}
180170

181-
return false
171+
return assertion.Skip || !supportedDialect(harness, assertion.Dialect)
182172
}
183173

184174
// TestScriptPrepared substitutes literals for bindvars, runs the test script given,
185175
// and makes any assertions given
186176
func TestScriptPrepared(t *testing.T, harness Harness, script queries.ScriptTest) bool {
187177
return t.Run(script.Name, func(t *testing.T) {
188-
if script.SkipPrepared {
189-
t.Skip()
190-
}
191-
192178
e := mustNewEngine(t, harness)
193179
defer e.Close()
194180
TestScriptWithEnginePrepared(t, e, harness, script)
@@ -198,6 +184,10 @@ func TestScriptPrepared(t *testing.T, harness Harness, script queries.ScriptTest
198184
// TestScriptWithEnginePrepared runs the test script with bindvars substituted for literals
199185
// using the engine provided.
200186
func TestScriptWithEnginePrepared(t *testing.T, e QueryEngine, harness Harness, script queries.ScriptTest) {
187+
if skipScript(harness, script, true) {
188+
t.Skip()
189+
}
190+
201191
ctx := NewContext(harness)
202192
err := CreateNewConnectionForServerEngine(ctx, e)
203193
require.NoError(t, err, nil)
@@ -227,13 +217,7 @@ func TestScriptWithEnginePrepared(t *testing.T, e QueryEngine, harness Harness,
227217

228218
for _, assertion := range assertions {
229219
t.Run(assertion.Query, func(t *testing.T) {
230-
231-
if sh, ok := harness.(SkippingHarness); ok {
232-
if sh.SkipQueryTest(assertion.Query) {
233-
t.Skip()
234-
}
235-
}
236-
if assertion.Skip {
220+
if skipAssertion(harness, assertion) {
237221
t.Skip()
238222
}
239223

0 commit comments

Comments
 (0)