Skip to content

Commit 5a9f8fe

Browse files
committed
Replace skip metadata with todo/invalid_syntax pattern
- Remove skipped_tests_by_size.txt file - Update parser_test.go to check for todo or invalid_syntax instead of skip - Change test flags from -run-skipped/-only-skipped to -run-todo/-only-todo - Update metadata.json files: - skip:true only -> todo:true (578 tests) - skip:true+invalid_syntax -> remove skip, keep invalid_syntax (66 tests) - skip:false -> empty object {} (379 tests) - Add cmd/next-test tool to find the next test to work on - Update CLAUDE.md with new workflow documentation
1 parent 4453b49 commit 5a9f8fe

File tree

1,027 files changed

+1125
-1910
lines changed

Some content is hidden

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

1,027 files changed

+1125
-1910
lines changed

CLAUDE.md

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,67 +2,44 @@
22

33
## Next Steps
44

5-
To continue implementing parser support for skipped tests, consult:
5+
To find the next test to work on, run:
66

7-
```
8-
skipped_tests_by_size.txt
7+
```bash
8+
go run ./cmd/next-test
99
```
1010

11-
This file lists all skipped tests ordered by query file size (smallest first). Smaller tests are generally simpler to implement.
11+
This tool finds all tests with `todo: true` in their metadata and returns the one with the shortest `query.sql` file.
1212

1313
## Workflow
1414

15-
1. Pick tests from `skipped_tests_by_size.txt` starting from the top
15+
1. Run `go run ./cmd/next-test` to find the next test to implement
1616
2. Check the test's `query.sql` to understand what SQL needs parsing
1717
3. Check the test's `ast.json` to understand the expected output format
1818
4. Implement the necessary AST types in `ast/`
1919
5. Add parser logic in `parser/parser.go`
2020
6. Add JSON marshaling functions in `parser/parser.go`
21-
7. Enable the test by setting `{"skip": false}` in its `metadata.json`
21+
7. Enable the test by removing `todo: true` from its `metadata.json` (set it to `{}`)
2222
8. Run `go test ./parser/...` to verify
23-
9. **Check if other skipped tests now pass** (see below)
24-
10. **Update `skipped_tests_by_size.txt`** after enabling tests
23+
9. **Check if other todo tests now pass** (see below)
2524

26-
## Checking for Newly Passing Skipped Tests
25+
## Checking for Newly Passing Todo Tests
2726

2827
After implementing parser changes, run:
2928

3029
```bash
31-
go test ./parser/... -only-skipped -v 2>&1 | grep "PASS:"
30+
go test ./parser/... -only-todo -v 2>&1 | grep "PASS:"
3231
```
3332

34-
This shows any skipped tests that now pass. Enable those tests by setting `{"skip": false}` in their `metadata.json`.
33+
This shows any todo tests that now pass. Enable those tests by removing `todo: true` from their `metadata.json`.
3534

3635
Available test flags:
37-
- `-only-skipped` - Run only skipped tests (find newly passing tests)
38-
- `-run-skipped` - Run skipped tests along with normal tests
39-
40-
## Updating skipped_tests_by_size.txt
41-
42-
After enabling tests, regenerate the file. The script only includes tests that:
43-
- Have `"skip": true` in metadata.json
44-
- Do NOT have `"invalid_syntax"` in metadata.json (these can't be implemented)
45-
- Have an `ast.json` file (tests without it are unparseable)
46-
47-
```bash
48-
cd parser/testdata
49-
ls -d */ | while read dir; do
50-
dir="${dir%/}"
51-
if [ -f "$dir/metadata.json" ] && [ -f "$dir/ast.json" ] && [ -f "$dir/query.sql" ]; then
52-
if grep -q '"skip": true' "$dir/metadata.json" 2>/dev/null; then
53-
if grep -qv '"invalid_syntax"' "$dir/metadata.json" 2>/dev/null; then
54-
size=$(wc -c < "$dir/query.sql")
55-
echo "$size $dir"
56-
fi
57-
fi
58-
fi
59-
done | sort -n > ../../skipped_tests_by_size.txt
60-
```
36+
- `-only-todo` - Run only todo/invalid_syntax tests (find newly passing tests)
37+
- `-run-todo` - Run todo/invalid_syntax tests along with normal tests
6138

6239
## Test Structure
6340

6441
Each test in `parser/testdata/` contains:
65-
- `metadata.json` - `{"skip": true}` or `{"skip": false}`
42+
- `metadata.json` - `{}` for enabled tests, `{"todo": true}` for pending tests, or `{"invalid_syntax": true}` for tests with invalid SQL
6643
- `query.sql` - T-SQL to parse
6744
- `ast.json` - Expected AST output
6845

cmd/next-test/main.go

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
"os"
7+
"path/filepath"
8+
"sort"
9+
)
10+
11+
type testMetadata struct {
12+
Todo bool `json:"todo"`
13+
}
14+
15+
type testInfo struct {
16+
Name string
17+
QueryLen int64
18+
}
19+
20+
func main() {
21+
testdataDir := "parser/testdata"
22+
entries, err := os.ReadDir(testdataDir)
23+
if err != nil {
24+
fmt.Fprintf(os.Stderr, "Error reading testdata directory: %v\n", err)
25+
os.Exit(1)
26+
}
27+
28+
var todoTests []testInfo
29+
30+
for _, entry := range entries {
31+
if !entry.IsDir() {
32+
continue
33+
}
34+
35+
testDir := filepath.Join(testdataDir, entry.Name())
36+
metadataPath := filepath.Join(testDir, "metadata.json")
37+
38+
metadataData, err := os.ReadFile(metadataPath)
39+
if err != nil {
40+
continue
41+
}
42+
43+
var metadata testMetadata
44+
if err := json.Unmarshal(metadataData, &metadata); err != nil {
45+
continue
46+
}
47+
48+
if !metadata.Todo {
49+
continue
50+
}
51+
52+
queryPath := filepath.Join(testDir, "query.sql")
53+
info, err := os.Stat(queryPath)
54+
if err != nil {
55+
continue
56+
}
57+
58+
todoTests = append(todoTests, testInfo{
59+
Name: entry.Name(),
60+
QueryLen: info.Size(),
61+
})
62+
}
63+
64+
if len(todoTests) == 0 {
65+
fmt.Println("No todo tests found!")
66+
return
67+
}
68+
69+
sort.Slice(todoTests, func(i, j int) bool {
70+
return todoTests[i].QueryLen < todoTests[j].QueryLen
71+
})
72+
73+
next := todoTests[0]
74+
fmt.Printf("%s (%d bytes)\n", next.Name, next.QueryLen)
75+
}

parser/parser_test.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ import (
1111
)
1212

1313
type testMetadata struct {
14-
Skip bool `json:"skip"`
14+
Todo bool `json:"todo"`
15+
InvalidSyntax bool `json:"invalid_syntax"`
1516
}
1617

17-
// Test flags for running skipped tests
18-
// Usage: go test ./parser/... -run-skipped # run all tests including skipped
19-
// Usage: go test ./parser/... -only-skipped # run only skipped tests (find newly passing tests)
20-
var runSkippedTests = flag.Bool("run-skipped", false, "run skipped tests along with normal tests")
21-
var onlySkippedTests = flag.Bool("only-skipped", false, "run only skipped tests (useful to find tests that now pass)")
18+
// Test flags for running todo/invalid_syntax tests
19+
// Usage: go test ./parser/... -run-todo # run all tests including todo tests
20+
// Usage: go test ./parser/... -only-todo # run only todo tests (find newly passing tests)
21+
var runTodoTests = flag.Bool("run-todo", false, "run todo tests along with normal tests")
22+
var onlyTodoTests = flag.Bool("only-todo", false, "run only todo tests (useful to find tests that now pass)")
2223

2324
func TestParse(t *testing.T) {
2425
entries, err := os.ReadDir("testdata")
@@ -35,7 +36,7 @@ func TestParse(t *testing.T) {
3536
t.Run(testName, func(t *testing.T) {
3637
testDir := filepath.Join("testdata", testName)
3738

38-
// Check metadata.json for skip flag
39+
// Check metadata.json for todo/invalid_syntax flags
3940
metadataPath := filepath.Join(testDir, "metadata.json")
4041
metadataData, err := os.ReadFile(metadataPath)
4142
if err != nil {
@@ -47,11 +48,13 @@ func TestParse(t *testing.T) {
4748
t.Fatalf("failed to parse metadata.json: %v", err)
4849
}
4950

50-
if metadata.Skip && !*runSkippedTests && !*onlySkippedTests {
51-
t.Skip("skipped via metadata.json")
51+
// Skip tests marked with todo or invalid_syntax unless running with -run-todo or -only-todo
52+
shouldSkip := metadata.Todo || metadata.InvalidSyntax
53+
if shouldSkip && !*runTodoTests && !*onlyTodoTests {
54+
t.Skip("skipped via metadata.json (todo or invalid_syntax)")
5255
}
53-
if !metadata.Skip && *onlySkippedTests {
54-
t.Skip("not a skipped test")
56+
if !shouldSkip && *onlyTodoTests {
57+
t.Skip("not a todo/invalid_syntax test")
5558
}
5659

5760
// Read the test SQL file
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"skip": false}
1+
{}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"skip": true}
1+
{"todo": true}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"skip": true,
3-
"invalid_syntax": true,
4-
"parser_error": "Line 2, Column 33: Incorrect syntax near '='.;Line 5, Column 33: Incorrect syntax near '='.;Line 8, Column 33: Incorrect syntax near '='.;Line 11, Column 33: Incorrect syntax near '='.;Line 14, Column 33: Incorrect syntax near '='.;Line 17, Column 33: Incorrect syntax near '='.;Line 20, Column 33: Incorrect syntax near '='.;Line 23, Column 48: Incorrect syntax near '='.;Line 26, Column 48: Incorrect syntax near '='.;Line 29, Column 48: Incorrect syntax near '='.;Line 32, Column 33: Incorrect syntax near '='.;Line 35, Column 33: Incorrect syntax near '='.;Line 38, Column 33: Incorrect syntax near '='.;Line 56, Column 48: Incorrect syntax near '='.;Line 63, Column 37: Incorrect syntax near '='.;"
5-
}
1+
{"invalid_syntax": true, "parser_error": "Line 2, Column 33: Incorrect syntax near '='.;Line 5, Column 33: Incorrect syntax near '='.;Line 8, Column 33: Incorrect syntax near '='.;Line 11, Column 33: Incorrect syntax near '='.;Line 14, Column 33: Incorrect syntax near '='.;Line 17, Column 33: Incorrect syntax near '='.;Line 20, Column 33: Incorrect syntax near '='.;Line 23, Column 48: Incorrect syntax near '='.;Line 26, Column 48: Incorrect syntax near '='.;Line 29, Column 48: Incorrect syntax near '='.;Line 32, Column 33: Incorrect syntax near '='.;Line 35, Column 33: Incorrect syntax near '='.;Line 38, Column 33: Incorrect syntax near '='.;Line 56, Column 48: Incorrect syntax near '='.;Line 63, Column 37: Incorrect syntax near '='.;"}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"skip": true,
3-
"invalid_syntax": true,
4-
"parser_error": "Line 1, Column 55: Incorrect syntax near 'USE'.;Line 2, Column 56: Incorrect syntax near 'USE'.;Line 3, Column 55: Incorrect syntax near 'USE'.;Line 4, Column 55: Incorrect syntax near 'USE'.;Line 5, Column 55: Incorrect syntax near 'USE'.;Line 6, Column 55: Incorrect syntax near 'USE'.;Line 7, Column 34: Incorrect syntax near 'USE'.;Line 35, Column 52: Incorrect syntax near 'USE'.;Line 40, Column 45: Incorrect syntax near 'USE'.;Line 45, Column 88: Incorrect syntax near 'USE'.;Line 53, Column 71: Incorrect syntax near 'USE'.;"
5-
}
1+
{"invalid_syntax": true, "parser_error": "Line 1, Column 55: Incorrect syntax near 'USE'.;Line 2, Column 56: Incorrect syntax near 'USE'.;Line 3, Column 55: Incorrect syntax near 'USE'.;Line 4, Column 55: Incorrect syntax near 'USE'.;Line 5, Column 55: Incorrect syntax near 'USE'.;Line 6, Column 55: Incorrect syntax near 'USE'.;Line 7, Column 34: Incorrect syntax near 'USE'.;Line 35, Column 52: Incorrect syntax near 'USE'.;Line 40, Column 45: Incorrect syntax near 'USE'.;Line 45, Column 88: Incorrect syntax near 'USE'.;Line 53, Column 71: Incorrect syntax near 'USE'.;"}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"skip": true}
1+
{"todo": true}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"skip": true}
1+
{"todo": true}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"skip": false}
1+
{}

0 commit comments

Comments
 (0)