-
Notifications
You must be signed in to change notification settings - Fork 561
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
[backport 0.7] Remove os.Exit calls from TestMain #3041
[backport 0.7] Remove os.Exit calls from TestMain #3041
Conversation
@jonathanbeber: This issue is currently awaiting triage. If CAPA/CAPI contributors determines this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Hi @jonathanbeber. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
part of #3038 |
we need #3043 to fix tests. |
@@ -52,11 +51,9 @@ func TestAPIs(t *testing.T) { | |||
} | |||
|
|||
func TestMain(m *testing.M) { | |||
code := 0 | |||
defer func() { os.Exit(code) }() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one will consume any panic, can confirm by adding a panic in any of the tests in the package.
~/Code/cluster-api-provider-aws(release-0.7)$ git diff
diff --git bootstrap/eks/api/v1alpha3/conversion_test.go bootstrap/eks/api/v1alpha3/conversion_test.go
index 9a3025df..b5b0449c 100644
--- bootstrap/eks/api/v1alpha3/conversion_test.go
+++ bootstrap/eks/api/v1alpha3/conversion_test.go
@@ -27,6 +27,7 @@ import (
)
func TestFuzzyConversion(t *testing.T) {
+ panic("test")
g := NewWithT(t)
scheme := runtime.NewScheme()
g.Expect(AddToScheme(scheme)).To(Succeed())
~/Code/cluster-api-provider-aws(release-0.7)$ go test -timeout 30s sigs.k8s.io/cluster-api-provider-aws/api/v1alpha3
ok sigs.k8s.io/cluster-api-provider-aws/api/v1alpha3 0.021s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for all other cases where we have defer func() { os.Exit(code) }()
or similar.
d4fb45e
to
dd3f0d3
Compare
As described in [go#34129], `os.Exit()` in the way we have in multiple tests in this project make panics to fail silently. That was first described in kubernetes-sigs#3032. Since go 1.15 the `os.Exit(code)` calls are not required, therefore, let's make panics visible and just run `m.Run()`. [go#34129]: golang/go#34129
dd3f0d3
to
040ba7a
Compare
This seems good to go |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sedefsavas The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind bug
/kind cleanup
What this PR does / why we need it:
As described in go#34129,
os.Exit()
in the way we have in multipletests in this project make panics to fail silently. That was first
described in #3032.
Since go 1.15 the
os.Exit(code)
calls are not required, therefore,let's make panics visible and just run
m.Run()
.Which issue(s) this PR fixes:
Fixes #3032
Special notes for your reviewer:
Checklist:
Release note: