From 9dab48812208e5a5f8528de747778e64056e6751 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Fri, 17 Jan 2020 14:20:01 +0100 Subject: [PATCH] =?UTF-8?q?Add=20`test-unit-update-golden`=20target=20to?= =?UTF-8?q?=20update=20golden=20files=20=F0=9F=90=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Errors should be ignored when running this 👼 Signed-off-by: Vincent Demeester --- Makefile | 5 +++++ hack/update-golden.sh | 5 +++++ 2 files changed, 10 insertions(+) create mode 100755 hack/update-golden.sh diff --git a/Makefile b/Makefile index dc8a169f19..1769be9a37 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 0000000000..96cf482127 --- /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