Skip to content

Commit e25a8b8

Browse files
committed
rename update-checks-doc script to check-checks
1 parent d63a8e1 commit e25a8b8

Some content is hidden

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

49 files changed

+25
-35
lines changed

CONTRIBUTING.md

+2-2

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +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
29+
go run ./scripts/check-checks -quiet ./docs/checks.md
3030
touch .staticchecktimestamp
3131

3232
l lint: .staticchecktimestamp
File renamed without changes.

scripts/update-checks-doc/README.md scripts/check-checks/README.md

+7-7

scripts/update-checks-doc/main.go scripts/check-checks/main.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,14 @@ func Update(in []byte) ([]byte, error) {
316316
var stderr io.Writer = os.Stderr
317317

318318
func Main(args []string) error {
319-
var check bool
319+
var fix bool
320320
var quiet bool
321321
flags := flag.NewFlagSet(args[0], flag.ContinueOnError)
322-
flags.BoolVar(&check, "check", false, "check the document is up-to-date")
322+
flags.BoolVar(&fix, "fix", false, "fix the outdated document automatically")
323323
flags.BoolVar(&quiet, "quiet", false, "disable trace logs")
324324
flags.SetOutput(stderr)
325325
flags.Usage = func() {
326-
fmt.Fprintln(stderr, "Usage: update-checks-doc [FLAGS] FILE\n\nFlags:")
326+
fmt.Fprintln(stderr, "Usage: check-checks [FLAGS] FILE\n\nFlags:")
327327
flags.PrintDefaults()
328328
}
329329

@@ -358,8 +358,8 @@ func Main(args []string) error {
358358
return nil
359359
}
360360

361-
if check {
362-
return fmt.Errorf("checks document has some update. run `go run ./scripts/update-checks-doc %s` and commit the changes. the diff:\n\n%s", path, cmp.Diff(in, out))
361+
if !fix {
362+
return fmt.Errorf("checks document has some update. run `go run ./scripts/check-checks -fix %s` and commit the changes on Linux or macOS. the diff:\n\n%s", path, cmp.Diff(in, out))
363363
}
364364

365365
log.Printf("Overwrite the file with the updated content (%d bytes) at %q", len(out), path)

scripts/update-checks-doc/main_test.go scripts/check-checks/main_test.go

+10-20
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func testErr(t *testing.T, err error, want ...string) {
4141

4242
func TestMainGenerateOK(t *testing.T) {
4343
if runtime.GOOS == "windows" {
44-
t.Skip("update-checks-doc doesn't support Windows")
44+
t.Skip("check-checks doesn't support Windows")
4545
}
4646
root := t.TempDir()
4747

@@ -52,7 +52,7 @@ func TestMainGenerateOK(t *testing.T) {
5252
in.Close()
5353
tmp.Close()
5454

55-
if err := Main([]string{"exe", path}); err != nil {
55+
if err := Main([]string{"exe", "-fix", path}); err != nil {
5656
t.Fatal(err)
5757
}
5858

@@ -65,20 +65,20 @@ func TestMainGenerateOK(t *testing.T) {
6565

6666
func TestMainCheckOK(t *testing.T) {
6767
if runtime.GOOS == "windows" {
68-
t.Skip("update-checks-doc doesn't support Windows")
68+
t.Skip("check-checks doesn't support Windows")
6969
}
7070
path := filepath.FromSlash("testdata/ok/minimal.out")
71-
if err := Main([]string{"exe", "-check", path}); err != nil {
71+
if err := Main([]string{"exe", path}); err != nil {
7272
t.Fatal(err)
7373
}
7474
}
7575

7676
func TestMainCheckQuietOK(t *testing.T) {
7777
if runtime.GOOS == "windows" {
78-
t.Skip("update-checks-doc doesn't support Windows")
78+
t.Skip("check-checks doesn't support Windows")
7979
}
8080
path := filepath.FromSlash("testdata/ok/minimal.out")
81-
if err := Main([]string{"exe", "-check", "-quiet", path}); err != nil {
81+
if err := Main([]string{"exe", "-quiet", path}); err != nil {
8282
t.Fatal(err)
8383
}
8484
}
@@ -91,14 +91,14 @@ func TestMainPrintHelp(t *testing.T) {
9191

9292
func TestMainCheckError(t *testing.T) {
9393
if runtime.GOOS == "windows" {
94-
t.Skip("update-checks-doc doesn't support Windows")
94+
t.Skip("check-checks doesn't support Windows")
9595
}
9696
path := filepath.FromSlash("testdata/ok/minimal.in")
97-
testErr(t, Main([]string{"exe", "-check", path}), "checks document has some update")
97+
testErr(t, Main([]string{"exe", path}), "checks document has some update")
9898
}
9999

100100
func TestMainFileNotFound(t *testing.T) {
101-
testErr(t, Main([]string{"exe", "-check", "this-file-does-not-exist.md"}), "could not read the document file")
101+
testErr(t, Main([]string{"exe", "this-file-does-not-exist.md"}), "could not read the document file")
102102
}
103103

104104
func TestMainTooManyArgs(t *testing.T) {
@@ -109,16 +109,6 @@ func TestMainInvalidCheckFlag(t *testing.T) {
109109
testErr(t, Main([]string{"exe", "-c", "foo.md"}), "flag provided but not defined")
110110
}
111111

112-
func TestMainNoUpdate(t *testing.T) {
113-
if runtime.GOOS == "windows" {
114-
t.Skip("update-checks-doc doesn't support Windows")
115-
}
116-
path := filepath.FromSlash("testdata/ok/minimal.out")
117-
if err := Main([]string{"exe", path}); err != nil {
118-
t.Fatal(err)
119-
}
120-
}
121-
122112
func TestMainUpdateError(t *testing.T) {
123113
path := filepath.FromSlash("testdata/err/no_playground_link.md")
124114
if err := Main([]string{"exe", path}); err == nil {
@@ -128,7 +118,7 @@ func TestMainUpdateError(t *testing.T) {
128118

129119
func TestUpdateOK(t *testing.T) {
130120
if runtime.GOOS == "windows" {
131-
t.Skip("update-checks-doc doesn't support Windows")
121+
t.Skip("check-checks doesn't support Windows")
132122
}
133123

134124
dir := filepath.FromSlash("testdata/ok")

0 commit comments

Comments
 (0)