Skip to content

Commit

Permalink
Merge pull request #33 from xmudrii/go-test-tags
Browse files Browse the repository at this point in the history
Add TestGoWithTags Mage target used to run go test with provided tags
  • Loading branch information
k8s-ci-robot committed Feb 8, 2022
2 parents 6dadf22 + 9489d95 commit 67865f3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mage/golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ func RunGolangCILint(version string, forceInstall bool, args ...string) error {
}

func TestGo(verbose bool, pkgs ...string) error {
return testGo(verbose, "", pkgs...)
}

func TestGoWithTags(verbose bool, tags string, pkgs ...string) error {
return testGo(verbose, tags, pkgs...)
}

func testGo(verbose bool, tags string, pkgs ...string) error {
verboseFlag := ""
if verbose {
verboseFlag = "-v"
Expand All @@ -166,6 +174,9 @@ func TestGo(verbose bool, pkgs ...string) error {

cmdArgs := []string{"test"}
cmdArgs = append(cmdArgs, verboseFlag)
if tags != "" {
cmdArgs = append(cmdArgs, "-tags", tags)
}
cmdArgs = append(cmdArgs, pkgArgs...)

if err := shx.RunV(
Expand Down

0 comments on commit 67865f3

Please sign in to comment.