From 71dc94b8ae55739aaa06223917af07b04d48bf02 Mon Sep 17 00:00:00 2001 From: Andrew Kroh Date: Thu, 22 Apr 2021 19:51:57 -0400 Subject: [PATCH] Fix broken generator tests, updates to go.sum needed Both generator tests were failing because the go.sum needed an update after running `mage test`. The tools.go file was not updated to include gotest.tools/gotestsum/cmd which is installed while running `mage test`. The original errors were: go: updates to go.sum needed, disabled by -mod=readonly Error: running "go build -o build/golang-crossbuild/testbeat-windows-amd64.exe -buildmode pie -ldflags -s -extldflags=-Wl,--nxcompat -X github.com/elastic/beats/v7/libbeat/version.buildTime=2021-04-22T20:49:55Z -X github.com/elastic/beats/v7/libbeat/version.commit=c3a7a6abdf2a15cfd685e82ce1fe502296509825" failed with exit code 1 Error: failed building for windows/amd64: exit status 1 failed building for windows/amd64: exit status 1 go: updates to go.sum needed, disabled by -mod=readonly Error: running "go build -o build/golang-crossbuild/testbeat-windows-386.exe -buildmode pie -ldflags -s -extldflags=-Wl,--nxcompat -X github.com/elastic/beats/v7/libbeat/version.buildTime=2021-04-22T20:49:55Z -X github.com/elastic/beats/v7/libbeat/version.commit=c3a7a6abdf2a15cfd685e82ce1fe502296509825" failed with exit code 1 Error: failed building for windows/386: exit status 1 failed building for windows/386: exit status 1 --- generator/_templates/beat/{beat}/tools/tools.go | 2 ++ generator/_templates/metricbeat/{beat}/tools/tools.go | 2 ++ generator/common/Makefile | 1 + 3 files changed, 5 insertions(+) diff --git a/generator/_templates/beat/{beat}/tools/tools.go b/generator/_templates/beat/{beat}/tools/tools.go index 289a0a2cb705..9b553081ae36 100644 --- a/generator/_templates/beat/{beat}/tools/tools.go +++ b/generator/_templates/beat/{beat}/tools/tools.go @@ -5,9 +5,11 @@ package tools import ( + _ "github.com/magefile/mage" _ "github.com/pierrre/gotestcover" _ "github.com/tsg/go-daemon" _ "golang.org/x/tools/cmd/goimports" + _ "gotest.tools/gotestsum/cmd" _ "github.com/mitchellh/gox" _ "golang.org/x/lint/golint" diff --git a/generator/_templates/metricbeat/{beat}/tools/tools.go b/generator/_templates/metricbeat/{beat}/tools/tools.go index 289a0a2cb705..9b553081ae36 100644 --- a/generator/_templates/metricbeat/{beat}/tools/tools.go +++ b/generator/_templates/metricbeat/{beat}/tools/tools.go @@ -5,9 +5,11 @@ package tools import ( + _ "github.com/magefile/mage" _ "github.com/pierrre/gotestcover" _ "github.com/tsg/go-daemon" _ "golang.org/x/tools/cmd/goimports" + _ "gotest.tools/gotestsum/cmd" _ "github.com/mitchellh/gox" _ "golang.org/x/lint/golint" diff --git a/generator/common/Makefile b/generator/common/Makefile index 8d82a444e84c..97f845d4b0d4 100644 --- a/generator/common/Makefile +++ b/generator/common/Makefile @@ -22,6 +22,7 @@ test: prepare-test test-package: test cd ${BEAT_PATH} ; \ export PATH=$${GOPATH}/bin:$${PATH}; \ + go mod tidy && \ mage package .PHONY: prepare-test