Skip to content

Commit

Permalink
Rename TestName parameter to avoid confusion.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmacknz committed Jul 11, 2023
1 parent ceefd77 commit 3948fd6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions dev-tools/mage/gotest.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
// GoTestArgs are the arguments used for the "go*Test" targets and they define
// how "go test" is invoked. "go test" is always invoked with -v for verbose.
type GoTestArgs struct {
TestName string // Test name used in logging.
LogName string // Test name used in logging.
RunExpr string // Expression to pass to the -run argument of go test.
Race bool // Enable race detector.
Tags []string // Build tags to enable.
Expand All @@ -50,7 +50,7 @@ type TestBinaryArgs struct {
func makeGoTestArgs(name string) GoTestArgs {
fileName := fmt.Sprintf("build/TEST-go-%s", strings.Replace(strings.ToLower(name), " ", "_", -1))
params := GoTestArgs{
TestName: name,
LogName: name,
Race: RaceDetector,
Packages: []string{"./..."},
OutputFile: fileName + ".out",
Expand All @@ -67,7 +67,7 @@ func makeGoTestArgsForModule(name, module string) GoTestArgs {
fileName := fmt.Sprintf("build/TEST-go-%s-%s", strings.Replace(strings.ToLower(name), " ", "_", -1),
strings.Replace(strings.ToLower(module), " ", "_", -1))
params := GoTestArgs{
TestName: fmt.Sprintf("%s-%s", name, module),
LogName: fmt.Sprintf("%s-%s", name, module),
Race: RaceDetector,
Packages: []string{fmt.Sprintf("./module/%s/...", module)},
OutputFile: fileName + ".out",
Expand Down Expand Up @@ -183,7 +183,7 @@ func InstallGoTestTools() {
func GoTest(ctx context.Context, params GoTestArgs) error {
mg.Deps(InstallGoTestTools)

fmt.Println(">> go test:", params.TestName, "Testing")
fmt.Println(">> go test:", params.LogName, "Testing")

// We use gotestsum to drive the tests and produce a junit report.
// The tool runs `go test -json` in order to produce a structured log which makes it easier
Expand Down Expand Up @@ -337,11 +337,11 @@ func GoTest(ctx context.Context, params GoTestArgs) error {

// Return an error indicating that testing failed.
if goTestErr != nil {
fmt.Println(">> go test:", params.TestName, "Test Failed")
fmt.Println(">> go test:", params.LogName, "Test Failed")
return errors.Wrap(goTestErr, "go test returned a non-zero value")
}

fmt.Println(">> go test:", params.TestName, "Test Passed")
fmt.Println(">> go test:", params.LogName, "Test Passed")
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion dev-tools/mage/gotest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestGoTest_CaptureOutput(t *testing.T) {
errNonZero := "go test returned a non-zero value"
makeArgs := func(test string) GoTestArgs {
return GoTestArgs{
TestName: "asserts",
LogName: "asserts",
Packages: []string{"."},
Env: map[string]string{envGoTestHelper: "1"},
ExtraFlags: []string{"-test.run", test},
Expand Down
2 changes: 1 addition & 1 deletion magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -1426,7 +1426,7 @@ func (Integration) TestOnRemote(ctx context.Context) error {
testName := fmt.Sprintf("remote-%s", testPrefix)
fileName := fmt.Sprintf("build/TEST-go-%s", testName)
params := mage.GoTestArgs{
TestName: testName,
LogName: testName,
OutputFile: fileName + ".out",
JUnitReportFile: fileName + ".xml",
Packages: []string{packageName},
Expand Down

0 comments on commit 3948fd6

Please sign in to comment.