diff --git a/Makefile b/Makefile index dc8a169f1..1769be9a3 100644 --- a/Makefile +++ b/Makefile @@ -60,6 +60,11 @@ test-unit: ./vendor ## run unit tests @echo "Running unit tests..." @go test -failfast -v -cover ./... +.PHONY: test-unit-update-golden +test-unit-update-golden: ./vendor ## run unit tests (updating golden files) + @echo "Running unit tests updating golden files..." + @./hack/update-golden.sh + .PHONY: test-e2e test-e2e: bin/tkn ## run e2e tests @echo "Running e2e tests..." diff --git a/hack/update-golden.sh b/hack/update-golden.sh new file mode 100755 index 000000000..96cf48212 --- /dev/null +++ b/hack/update-golden.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# This will run `go test a/package -test.update-golden=true` on all packages that are importing `gotest.tools/v3/golden` +# This will update the golden files with the current output. +# Run this only when you are sure the output is meant to change. +go test $(go list -f '{{ .ImportPath }} {{ .TestImports }}' ./... | grep gotest.tools/v3/golden | awk '{print $1}' | tr '\n' ' ') -test.update-golden=true