Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run unit and integration tests with gotestsum #22541

Merged
merged 34 commits into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d35fd1c
Creating failing tests, test cases
Nov 11, 2020
b629d7b
Rewrite mage go test based on gotestsum
Nov 16, 2020
81a34eb
Merge branch 'master' into test_reports_incomplete
Nov 16, 2020
13b252b
Fix lint on tests
Nov 18, 2020
9d8e563
print go test output directly
Nov 18, 2020
747a429
clean up go.mod after installing go based tool
Nov 18, 2020
53717ea
Merge branch 'master' into test_reports_incomplete
Nov 19, 2020
4f7cb68
lets try with go get
Nov 19, 2020
0b98e70
try to switch to another directory before when installing gotestsum
Nov 20, 2020
7629ccb
Add gotestsum to heartbeat docker image for testing
Nov 20, 2020
2170d7e
fix verbosity mode
Dec 8, 2020
6e659b9
Merge branch 'master' into test_reports_incomplete
Dec 8, 2020
d2eff71
remove leftover debug output
Dec 9, 2020
1f3c661
Merge branch 'master' into test_reports_incomplete
Dec 24, 2020
8268937
Add gotestsum to metricbeat dockerfile
Dec 24, 2020
d5af77d
Merge branch 'master' into test_reports_incomplete
Dec 28, 2020
c576b27
Add missing gotestsum to Dockerfiles
Dec 28, 2020
c1ddf3f
Add unit tests for GoTest
Dec 29, 2020
91a86ed
remove test output tests from filebeat
Dec 29, 2020
e4a7dfc
fix notice file
Dec 29, 2020
ac578cb
Update common/cli tests to capture output as well
Dec 30, 2020
2d7b0e3
one more missing gotestsum
Dec 30, 2020
f393fdf
Do not upgrade x/sys
Dec 30, 2020
c567e11
use go.mod from master
Dec 30, 2020
a06fcd2
gotest testing cleanups and minor fixes
Dec 30, 2020
6448cb2
remove GoTestSummary
Jan 4, 2021
b015a84
Merge branch 'master' into test_reports_incomplete
Jan 4, 2021
e61ea51
Merge branch 'master' into test_reports_incomplete
Jan 12, 2021
942f413
remove go-junit-reporter from go.mod
Jan 12, 2021
5cabf71
update notice
Jan 12, 2021
e75a323
Install gotestsum via mage
Jan 12, 2021
28de5cc
Merge branch 'master' into test_reports_incomplete
Jan 12, 2021
703fcf5
fix import order
Jan 13, 2021
69b3387
Try to fix build by updating indirect dependency psutil
Jan 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
gotest testing cleanups and minor fixes
  • Loading branch information
urso committed Dec 30, 2020
commit a06fcd25699946a00395cbf6578f379c57929231
24 changes: 18 additions & 6 deletions dev-tools/mage/gotest.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,31 @@ func GoTestIntegrationForModule(ctx context.Context) error {
func GoTest(ctx context.Context, params GoTestArgs) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we create a InstallGotestsum target and add it here as dependency?

Suggested change
func GoTest(ctx context.Context, params GoTestArgs) error {
func GoTest(ctx context.Context, params GoTestArgs) error {
mg.Deps(InstallGotestsum)

We do this with InstallGoLicenser for example.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will give this a try. Thanks.

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

toolsArgs := []string{"--no-color"}
// 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
// to parse the actual test output.
// Of OutputFile is given the original JSON file will be written as well.
//
// The runner needs to set CLI flags for gotestsum and for "go test". We track the different
// CLI flags in the gotestsumArgs and testArgs variables, such that we can finally produce command like:
// $ gotestsum <gotestsum args> -- <go test args>
//
// The additional arguments given via GoTestArgs are applied to `go test` only. Callers can not
// modify any of the gotestsum arguments.

gotestsumArgs := []string{"--no-color"}
if mg.Verbose() {
toolsArgs = append(toolsArgs, "-f", "standard-verbose")
gotestsumArgs = append(gotestsumArgs, "-f", "standard-verbose")
} else {
toolsArgs = append(toolsArgs, "-f", "standard-quiet")
gotestsumArgs = append(gotestsumArgs, "-f", "standard-quiet")
}
if params.JUnitReportFile != "" {
CreateDir(params.JUnitReportFile)
toolsArgs = append(toolsArgs, "--junitfile", params.JUnitReportFile)
gotestsumArgs = append(gotestsumArgs, "--junitfile", params.JUnitReportFile)
}
if params.OutputFile != "" {
CreateDir(params.OutputFile)
toolsArgs = append(toolsArgs, "--jsonfile", params.OutputFile+".json")
gotestsumArgs = append(gotestsumArgs, "--jsonfile", params.OutputFile+".json")
}

var testArgs []string
Expand All @@ -226,7 +238,7 @@ func GoTest(ctx context.Context, params GoTestArgs) error {
testArgs = append(testArgs, params.ExtraFlags...)
testArgs = append(testArgs, params.Packages...)

args := append(toolsArgs, append([]string{"--"}, testArgs...)...)
args := append(gotestsumArgs, append([]string{"--"}, testArgs...)...)

goTest := makeCommand(ctx, params.Env, "gotestsum", args...)
// Wire up the outputs.
Expand Down
Loading