Skip to content

Commit 3ec3ae3

Browse files
committed
Separate make command -> make update-golden-files
1 parent 7f6b0f4 commit 3ec3ae3

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ gotests.coverage
1818
.gitpod.yml
1919
.DS_Store
2020

21+
# Make target for updating golden files.
22+
cli/testdata/.gen-golden
23+
2124
# Front-end ignore
2225
.next/
2326
site/.eslintcache

Makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,15 +394,13 @@ gen: \
394394
coderd/database/querier.go \
395395
provisionersdk/proto/provisioner.pb.go \
396396
provisionerd/proto/provisionerd.pb.go \
397-
site/src/api/typesGenerated.ts \
398-
cli/testdata/golden
397+
site/src/api/typesGenerated.ts
399398
.PHONY: gen
400399

401400
# Mark all generated files as fresh so make thinks they're up-to-date. This is
402401
# used during releases so we don't run generation scripts.
403402
gen/mark-fresh:
404403
files="coderd/database/dump.sql coderd/database/querier.go provisionersdk/proto/provisioner.pb.go provisionerd/proto/provisionerd.pb.go site/src/api/typesGenerated.ts"
405-
files=($$files cli/testdata/*.golden)
406404
for file in "$${files[@]}"; do
407405
echo "$$file"
408406
if [ ! -f "$$file" ]; then
@@ -445,9 +443,14 @@ site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find codersdk
445443
cd site
446444
yarn run format:types
447445

448-
cli/testdata/golden: $(wildcard cli/testdata/*.golden)
446+
update-golden-files: cli/testdata/.gen-golden
447+
.PHONY: update-golden-files
448+
449+
cli/testdata/.gen-golden: $(wildcard cli/testdata/*.golden) \
450+
$(shell find . -not -path './vendor/*' -type f -name '*.go')
451+
449452
go test ./cli -run=TestCommandHelp -update
450-
.PHONY: cli/testdata/golden
453+
touch "$@"
451454

452455
test: test-clean
453456
gotestsum -- -v -short ./...

cli/root_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ func TestCommandHelp(t *testing.T) {
8282
}
8383

8484
want, err := os.ReadFile(gf)
85-
require.NoError(t, err, "read golden file, run \"make gen\" and commit the changes")
85+
require.NoError(t, err, "read golden file, run \"make update-golden-files\" and commit the changes")
8686
got := buf.Bytes()
87-
require.Equal(t, string(want), string(got), "golden file mismatch: %s, run \"make gen\", verify and commit the changes", gf)
87+
require.Equal(t, string(want), string(got), "golden file mismatch: %s, run \"make update-golden-files\", verify and commit the changes", gf)
8888
})
8989
}
9090
}

0 commit comments

Comments
 (0)