Skip to content

Commit ae5d2e4

Browse files
committed
add -quiet flag to update-checks-doc script
and run the script in `make lint`
1 parent 54f7d98 commit ae5d2e4

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ jobs:
104104
echo "$diffs" >&2
105105
exit 1
106106
fi
107-
- name: Check `docs/checks.md` is up-to-date
108-
run: go run ./scripts/update-checks-doc -check ./docs/checks.md
109107
- name: Install staticcheck
110108
run: |
111109
go install honnef.co/go/tools/cmd/staticcheck@latest

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ t test: .testtimestamp
2626
.staticchecktimestamp: $(TESTS) $(SRCS) $(TOOL)
2727
staticcheck ./...
2828
GOOS=js GOARCH=wasm staticcheck ./playground
29+
go run ./scripts/update-checks-doc -check -quiet ./docs/checks.md
2930
touch .staticchecktimestamp
3031

3132
l lint: .staticchecktimestamp

scripts/update-checks-doc/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,13 +317,16 @@ var stderr io.Writer = os.Stderr
317317

318318
func Main(args []string) error {
319319
var check bool
320+
var quiet bool
320321
flags := flag.NewFlagSet(args[0], flag.ContinueOnError)
321322
flags.BoolVar(&check, "check", false, "check the document is up-to-date")
323+
flags.BoolVar(&quiet, "quiet", false, "disable trace logs")
322324
flags.SetOutput(stderr)
323325
flags.Usage = func() {
324326
fmt.Fprintln(stderr, "Usage: update-checks-doc [FLAGS] FILE\n\nFlags:")
325327
flags.PrintDefaults()
326328
}
329+
327330
if err := flags.Parse(args[1:]); err != nil {
328331
if err == flag.ErrHelp {
329332
return nil
@@ -335,6 +338,10 @@ func Main(args []string) error {
335338
}
336339
path := flags.Arg(0)
337340

341+
if quiet {
342+
log.SetOutput(io.Discard)
343+
}
344+
338345
in, err := os.ReadFile(path)
339346
if err != nil {
340347
return fmt.Errorf("could not read the document file: %w", err)

scripts/update-checks-doc/main_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ func TestMainCheckOK(t *testing.T) {
7373
}
7474
}
7575

76+
func TestMainCheckQuietOK(t *testing.T) {
77+
if runtime.GOOS == "windows" {
78+
t.Skip("update-checks-doc doesn't support Windows")
79+
}
80+
path := filepath.FromSlash("testdata/ok/minimal.out")
81+
if err := Main([]string{"exe", "-check", "-quiet", path}); err != nil {
82+
t.Fatal(err)
83+
}
84+
}
85+
7686
func TestMainPrintHelp(t *testing.T) {
7787
if err := Main([]string{"exe", "-help"}); err != nil {
7888
t.Fatal(err)

0 commit comments

Comments
 (0)