Skip to content

Commit 03fef2b

Browse files
committed
Add explain_todo metadata to skip specific statement tests
Add support for explain_todo in metadata.json to skip individual statement subtests. This allows marking specific statements as pending without skipping the entire test case. Usage in metadata.json: {"explain_todo": {"stmt2": true, "stmt5": true}} This skips stmt2 and stmt5 subtests while running all other statements.
1 parent c41a93e commit 03fef2b

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

parser/parser_test.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ var checkFormat = flag.Bool("check-format", false, "Run skipped todo_format test
2525

2626
// testMetadata holds optional metadata for a test case
2727
type testMetadata struct {
28-
Todo bool `json:"todo,omitempty"`
29-
TodoFormat bool `json:"todo_format,omitempty"` // true if format roundtrip test is pending
30-
Source string `json:"source,omitempty"`
31-
Explain *bool `json:"explain,omitempty"`
32-
Skip bool `json:"skip,omitempty"`
33-
ParseError bool `json:"parse_error,omitempty"` // true if query is intentionally invalid SQL
28+
Todo bool `json:"todo,omitempty"`
29+
TodoFormat bool `json:"todo_format,omitempty"` // true if format roundtrip test is pending
30+
ExplainTodo map[string]bool `json:"explain_todo,omitempty"` // map of stmtN -> true to skip specific statements
31+
Source string `json:"source,omitempty"`
32+
Explain *bool `json:"explain,omitempty"`
33+
Skip bool `json:"skip,omitempty"`
34+
ParseError bool `json:"parse_error,omitempty"` // true if query is intentionally invalid SQL
3435
}
3536

3637
// splitStatements splits SQL content into individual statements.
@@ -119,6 +120,7 @@ func findCommentStart(line string) int {
119120
// - explain: false to skip the test (e.g., when ClickHouse couldn't parse it)
120121
// - skip: true to skip the test entirely (e.g., causes infinite loop)
121122
// - parse_error: true if the query is intentionally invalid SQL (expected to fail parsing)
123+
// - explain_todo: map of stmtN -> true to skip specific statements (e.g., {"stmt2": true, "stmt5": true})
122124
// - explain.txt: Expected EXPLAIN AST output for first statement
123125
// - explain_N.txt: Expected EXPLAIN AST output for Nth statement (N >= 2)
124126
func TestParser(t *testing.T) {
@@ -198,6 +200,13 @@ func TestParser(t *testing.T) {
198200
}
199201
}
200202

203+
// Skip statements marked in explain_todo
204+
stmtKey := fmt.Sprintf("stmt%d", stmtIndex)
205+
if metadata.ExplainTodo[stmtKey] {
206+
t.Skipf("TODO: explain_todo[%s] is true", stmtKey)
207+
return
208+
}
209+
201210
// Create context with 1 second timeout
202211
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
203212
defer cancel()

0 commit comments

Comments
 (0)