Skip to content

Commit b25da58

Browse files
mpywclaude
andcommitted
fix: add test to structure.json, document ./test_all.sh
- Add goodErrgroupWithContextForLoop to structure.json - Update CLAUDE.md to emphasize using ./test_all.sh before committing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1ba257c commit b25da58

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

CLAUDE.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,25 +176,24 @@ The gotask checker handles `github.com/siketyan/gotask` library:
176176
## Development Commands
177177
178178
```bash
179-
# Run all tests
180-
go test ./...
181-
182-
# Run tests with verbose output
183-
go test -v ./...
179+
# Run ALL tests (ALWAYS use this before committing)
180+
./test_all.sh
184181

185182
# Run golangci-lint
186183
golangci-lint run ./...
187184

188185
# Format code
189186
go fmt ./...
190-
191-
# Validate test metadata (structure.json)
192-
cd testdata/metatest && go test -v ./...
193-
194-
# Validate JSON schema
195-
cd testdata/metatest && go run github.com/santhosh-tekuri/jsonschema/cmd/jv@29cbed9 structure.schema.json structure.json
196187
```
197188

189+
> [!IMPORTANT]
190+
> Always use `./test_all.sh` before committing. This script runs:
191+
> 1. JSON schema validation for `structure.json`
192+
> 2. Test metadata validation (ensures all test functions are in `structure.json`)
193+
> 3. All analyzer tests
194+
>
195+
> Running only `go test ./...` will miss structure validation failures.
196+
198197
## Adding a New Checker
199198

200199
1. Create `internal/checkers/<name>/checker.go`:

test_all.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
set -x
4+
5+
go run github.com/santhosh-tekuri/jsonschema/cmd/jv@29cbed9 testdata/metatest/structure.schema.json testdata/metatest/structure.json
6+
go test ./testdata/metatest/validation_test.go
7+
go test -v ./...

testdata/metatest/structure.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,6 +2148,22 @@
21482148
},
21492149
"level": "basic"
21502150
},
2151+
"derivedCtxInForLoopWithFunctionVariable": {
2152+
"title": "Derived ctx in for loop with function variable",
2153+
"targets": [
2154+
"errgroup"
2155+
],
2156+
"variants": {
2157+
"good": {
2158+
"description": "Real-world production pattern: derived ctx used in closure inside for loop",
2159+
"functions": {
2160+
"errgroup": "goodErrgroupWithContextForLoop"
2161+
}
2162+
},
2163+
"bad": null
2164+
},
2165+
"level": "basic"
2166+
},
21512167
"literalWithDerivedCtxWithDefer": {
21522168
"title": "Literal with derived ctx - with defer",
21532169
"targets": [

0 commit comments

Comments
 (0)