From 3986c92379760791473e00a46eebda4181a30009 Mon Sep 17 00:00:00 2001 From: David Bariod Date: Sat, 13 Feb 2021 06:45:48 +0100 Subject: [PATCH] add a test target in the magefile --- .travis.yml | 5 +---- magefile.go | 8 +++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1d8a09f..e6ee8b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,4 @@ install: script: - go run mage.go -v crossBuild - go run mage.go lint - - export GOMAXPROCS=4 - - export GORACE=halt_on_error=1 - - go test -race -v ./... - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then go test -race -v -tags appengine ./... ; fi + - go run mage.go test diff --git a/magefile.go b/magefile.go index 02e05de..9aa6039 100644 --- a/magefile.go +++ b/magefile.go @@ -12,7 +12,7 @@ import ( "github.com/magefile/mage/sh" ) -// GenBuildMatrix regenerates the build matrix from the current version of the go compiler +// getBuildMatrix returns the build matrix from the current version of the go compiler func getBuildMatrix() (map[string][]string, error) { jsonData, err := sh.Output("go", "tool", "dist", "list", "-json") if err != nil { @@ -69,3 +69,9 @@ func Lint() error { return sh.Run(path.Join(gopath, "bin", "golangci-lint"), "run", "./...") } + +// Run the test suite +func Test() error { + return sh.RunWith(map[string]string{"GORACE": "halt_on_error=1"}, + "go", "test", "-race", "-v", "./...") +}