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

Fix revive warning in testmain.go files #3958

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Changes from all commits
Commits
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
Fix revive warning in testmain.go files
When configuring nogo() to run the revive linter, we currently see
builds of testmain.go files fail with the following error:

    if block ends with call to os.Exit function, so drop this else and outdent its block (move short variable declaration to its own line if necessary)

Let's restructure this code slightly, so that this is no longer an
issue.
  • Loading branch information
EdSchouten authored and fmeum committed Jun 11, 2024
commit cd30a2ade6f7e85008052002904ca5dac801a219
8 changes: 4 additions & 4 deletions go/tools/builders/generate_test_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,14 @@ func testsInShard() []testing.InternalTest {
func main() {
if bzltestutil.ShouldWrap() {
err := bzltestutil.Wrap("{{.Pkgname}}")
exitCode := 0
if xerr, ok := err.(*exec.ExitError); ok {
os.Exit(xerr.ExitCode())
exitCode = xerr.ExitCode()
} else if err != nil {
log.Print(err)
os.Exit(bzltestutil.TestWrapperAbnormalExit)
} else {
os.Exit(0)
exitCode = bzltestutil.TestWrapperAbnormalExit
}
os.Exit(exitCode)
}

testDeps :=
Expand Down