Skip to content

Commit 0fa0ccc

Browse files
authored
Add -only-skipped and -run-skipped test flags (#14)
1 parent 29e8add commit 0fa0ccc

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

CLAUDE.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,22 @@ This file lists all skipped tests ordered by query file size (smallest first). S
2020
6. Add JSON marshaling functions in `parser/parser.go`
2121
7. Enable the test by setting `{"skip": false}` in its `metadata.json`
2222
8. Run `go test ./parser/...` to verify
23-
9. **Update `skipped_tests_by_size.txt`** after enabling tests
23+
9. **Check if other skipped tests now pass** (see below)
24+
10. **Update `skipped_tests_by_size.txt`** after enabling tests
25+
26+
## Checking for Newly Passing Skipped Tests
27+
28+
After implementing parser changes, run:
29+
30+
```bash
31+
go test ./parser/... -only-skipped -v 2>&1 | grep "PASS:"
32+
```
33+
34+
This shows any skipped tests that now pass. Enable those tests by setting `{"skip": false}` in their `metadata.json`.
35+
36+
Available test flags:
37+
- `-only-skipped` - Run only skipped tests (find newly passing tests)
38+
- `-run-skipped` - Run skipped tests along with normal tests
2439

2540
## Updating skipped_tests_by_size.txt
2641

parser/parser_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"context"
66
"encoding/json"
7+
"flag"
78
"os"
89
"path/filepath"
910
"testing"
@@ -13,6 +14,12 @@ type testMetadata struct {
1314
Skip bool `json:"skip"`
1415
}
1516

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)")
22+
1623
func TestParse(t *testing.T) {
1724
entries, err := os.ReadDir("testdata")
1825
if err != nil {
@@ -40,9 +47,12 @@ func TestParse(t *testing.T) {
4047
t.Fatalf("failed to parse metadata.json: %v", err)
4148
}
4249

43-
if metadata.Skip {
50+
if metadata.Skip && !*runSkippedTests && !*onlySkippedTests {
4451
t.Skip("skipped via metadata.json")
4552
}
53+
if !metadata.Skip && *onlySkippedTests {
54+
t.Skip("not a skipped test")
55+
}
4656

4757
// Read the test SQL file
4858
sqlPath := filepath.Join(testDir, "query.sql")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"skip": true}
1+
{"skip": false}

skipped_tests_by_size.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
203 Baselines160_CreateExternalFileFormatStatementTests160
3131
208 BaselinesCommon_AlterProcedureStatementTests
3232
208 RowsetsInSelectTests100
33-
210 AlterCreateCredentialStatementTests
3433
213 Baselines150_AlterDatabaseScopedConfigClearProcCacheTests150
3534
213 DeclareTableVariableTests150
3635
217 Baselines90_ExecuteAsStatementTests
@@ -44,15 +43,13 @@
4443
225 AlterServerConfigurationExternalAuthenticationTests150
4544
225 DeclareTableStatementTests
4645
226 Baselines90_RowsetsInSelectTests90
47-
231 Baselines90_AlterTableSwitchStatementTests
4846
231 Baselines90_ExecuteStatementTests90
4947
233 AlterResourceGovernorStatementTests
5048
233 Baselines100_AlterResourceGovernorStatementTests
5149
235 AlterFulltextCatalogStatementTests
5250
235 UseFederationTests110
5351
236 AlterTableStatementTests140_Azure
5452
236 Baselines140_AlterTableStatementTests140_Azure
55-
236 Baselines90_AlterCreateCredentialStatementTests
5653
239 Baselines100_EventNotificationStatementTests100
5754
239 Baselines120_AlterDatabaseOptionsTests120
5855
239 Baselines160_FuzzyStringMatchingTests160
@@ -161,7 +158,6 @@
161158
379 AlterCreateServiceStatementTests
162159
382 Baselines90_AlterCreateServiceStatementTests
163160
382 TableParametersTests
164-
383 AlterTableSwitchStatementTests
165161
384 BitManipulationFunctionTests160
166162
385 Baselines100_SymmetricKeyStatementTests100
167163
386 Baselines100_CTEStatementTests100

0 commit comments

Comments
 (0)