Skip to content

Commit 761ca2a

Browse files
authored
Remove normalize and format packages and format testing (#66)
1 parent 8fffa8c commit 761ca2a

File tree

4,363 files changed

+25964
-6631
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,363 files changed

+25964
-6631
lines changed

CLAUDE.md

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,11 @@
55
To find the next explain test to work on (fewest pending statements first), run:
66

77
```bash
8-
go run ./cmd/next-test -explain
8+
go run ./cmd/next-test
99
```
1010

1111
This finds tests with `explain_todo` entries in their metadata.
1212

13-
To find the next format roundtrip test to work on, run:
14-
15-
```bash
16-
go run ./cmd/next-test -format
17-
```
18-
19-
This finds tests with `todo_format: true` in their metadata.
20-
2113
## Running Tests
2214

2315
Always run parser tests with a 5 second timeout:
@@ -28,16 +20,6 @@ go test ./parser/... -timeout 5s
2820

2921
The tests are very fast. If a test is timing out, it indicates a bug (likely an infinite loop in the parser).
3022

31-
## Checking for Newly Passing Format Tests
32-
33-
After implementing format changes, run:
34-
35-
```bash
36-
go test ./parser/... -check-format -v 2>&1 | grep "FORMAT PASSES NOW"
37-
```
38-
39-
Tests that output `FORMAT PASSES NOW` can have their `todo_format` flag removed from `metadata.json`.
40-
4123
## Checking for Newly Passing Explain Tests
4224

4325
After implementing parser/explain changes, run:
@@ -59,7 +41,6 @@ Each test in `parser/testdata/` contains:
5941

6042
### Metadata Options
6143

62-
- `todo_format: true` - Format roundtrip test is pending implementation
6344
- `explain_todo: {"stmt2": true}` - Skip specific statement subtests
6445
- `skip: true` - Skip test entirely (e.g., causes infinite loop)
6546
- `explain: false` - Skip test (e.g., ClickHouse couldn't parse it)

cmd/next-test/main.go

Lines changed: 21 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,13 @@ package main
22

33
import (
44
"encoding/json"
5-
"flag"
65
"fmt"
76
"os"
87
"path/filepath"
98
"sort"
109
)
1110

12-
var formatFlag = flag.Bool("format", false, "Find tests with todo_format: true")
13-
var explainFlag = flag.Bool("explain", false, "Find tests with explain_todo entries (fewest first)")
14-
1511
type testMetadata struct {
16-
TodoFormat bool `json:"todo_format,omitempty"`
1712
ExplainTodo map[string]bool `json:"explain_todo,omitempty"`
1813
Explain *bool `json:"explain,omitempty"`
1914
Skip bool `json:"skip,omitempty"`
@@ -27,15 +22,6 @@ type todoTest struct {
2722
}
2823

2924
func main() {
30-
flag.Parse()
31-
32-
if !*formatFlag && !*explainFlag {
33-
fmt.Fprintf(os.Stderr, "Usage: go run ./cmd/next-test [-format | -explain]\n")
34-
fmt.Fprintf(os.Stderr, " -format Find tests with todo_format: true\n")
35-
fmt.Fprintf(os.Stderr, " -explain Find tests with explain_todo entries (fewest first)\n")
36-
os.Exit(1)
37-
}
38-
3925
testdataDir := "parser/testdata"
4026
entries, err := os.ReadDir(testdataDir)
4127
if err != nil {
@@ -69,15 +55,9 @@ func main() {
6955
continue
7056
}
7157

72-
// Check based on flag
73-
if *formatFlag {
74-
if !metadata.TodoFormat {
75-
continue
76-
}
77-
} else if *explainFlag {
78-
if len(metadata.ExplainTodo) == 0 {
79-
continue
80-
}
58+
// Check for explain_todo entries
59+
if len(metadata.ExplainTodo) == 0 {
60+
continue
8161
}
8262

8363
// Read query to get its size
@@ -94,41 +74,24 @@ func main() {
9474
})
9575
}
9676

97-
todoType := "todo_format"
98-
if *explainFlag {
99-
todoType = "explain_todo"
100-
}
101-
10277
if len(todoTests) == 0 {
103-
fmt.Printf("No %s tests found!\n", todoType)
78+
fmt.Printf("No explain_todo tests found!\n")
10479
return
10580
}
10681

107-
// Sort based on mode
108-
if *explainFlag {
109-
// Sort by explain_todo count (fewest first), then by query size
110-
sort.Slice(todoTests, func(i, j int) bool {
111-
if todoTests[i].explainTodoLen != todoTests[j].explainTodoLen {
112-
return todoTests[i].explainTodoLen < todoTests[j].explainTodoLen
113-
}
114-
return todoTests[i].querySize < todoTests[j].querySize
115-
})
116-
} else {
117-
// Sort by query size (shortest first)
118-
sort.Slice(todoTests, func(i, j int) bool {
119-
return todoTests[i].querySize < todoTests[j].querySize
120-
})
121-
}
82+
// Sort by explain_todo count (fewest first), then by query size
83+
sort.Slice(todoTests, func(i, j int) bool {
84+
if todoTests[i].explainTodoLen != todoTests[j].explainTodoLen {
85+
return todoTests[i].explainTodoLen < todoTests[j].explainTodoLen
86+
}
87+
return todoTests[i].querySize < todoTests[j].querySize
88+
})
12289

12390
// Print the best candidate
12491
next := todoTests[0]
12592
testDir := filepath.Join(testdataDir, next.name)
12693

127-
if *explainFlag {
128-
fmt.Printf("Next %s test: %s (%d pending statements)\n\n", todoType, next.name, next.explainTodoLen)
129-
} else {
130-
fmt.Printf("Next %s test: %s\n\n", todoType, next.name)
131-
}
94+
fmt.Printf("Next explain_todo test: %s (%d pending statements)\n\n", next.name, next.explainTodoLen)
13295

13396
// Print query.sql contents
13497
queryPath := filepath.Join(testDir, "query.sql")
@@ -141,19 +104,17 @@ func main() {
141104
fmt.Printf("\nExpected EXPLAIN output:\n%s\n", string(explainBytes))
142105
}
143106

144-
// Print explain_todo entries if in explain mode
145-
if *explainFlag {
146-
metadataPath := filepath.Join(testDir, "metadata.json")
147-
if metadataBytes, err := os.ReadFile(metadataPath); err == nil {
148-
var metadata testMetadata
149-
if json.Unmarshal(metadataBytes, &metadata) == nil {
150-
fmt.Printf("\nPending statements (explain_todo):\n")
151-
for stmt := range metadata.ExplainTodo {
152-
fmt.Printf(" - %s\n", stmt)
153-
}
107+
// Print explain_todo entries
108+
metadataPath := filepath.Join(testDir, "metadata.json")
109+
if metadataBytes, err := os.ReadFile(metadataPath); err == nil {
110+
var metadata testMetadata
111+
if json.Unmarshal(metadataBytes, &metadata) == nil {
112+
fmt.Printf("\nPending statements (explain_todo):\n")
113+
for stmt := range metadata.ExplainTodo {
114+
fmt.Printf(" - %s\n", stmt)
154115
}
155116
}
156117
}
157118

158-
fmt.Printf("\nRemaining %s tests: %d\n", todoType, len(todoTests))
119+
fmt.Printf("\nRemaining explain_todo tests: %d\n", len(todoTests))
159120
}

0 commit comments

Comments
 (0)