Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 1 addition & 4 deletions api/v1alpha3/webhook_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package v1alpha3

import (
"fmt"
"os"
"path"
"testing"

Expand Down Expand Up @@ -52,11 +51,9 @@ func TestAPIs(t *testing.T) {
}

func TestMain(m *testing.M) {
code := 0
defer func() { os.Exit(code) }()
Copy link
Contributor Author

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

Copy link
Contributor Author

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.

setup()
defer teardown()
code = m.Run()
m.Run()
}

func setup() {
Expand Down
6 changes: 2 additions & 4 deletions api/v1alpha4/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package v1alpha4

import (
"fmt"
"os"
"path"
"testing"

Expand Down Expand Up @@ -47,9 +46,8 @@ func TestAPIs(t *testing.T) {

func TestMain(m *testing.M) {
setup()
code := m.Run()
teardown()
os.Exit(code)
defer teardown()
m.Run()
}

func setup() {
Expand Down
9 changes: 3 additions & 6 deletions bootstrap/eks/api/v1alpha3/webhook_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package v1alpha3

import (
"fmt"
"os"
"path"
"testing"

Expand All @@ -36,21 +35,19 @@ var (
)

func TestMain(m *testing.M) {
code := 0
defer func() { os.Exit(code) }()
setup()
defer teardown()
code = m.Run()
m.Run()
}

func setup() {
utilruntime.Must(AddToScheme(scheme.Scheme))
utilruntime.Must(bootstrapv1alpha4.AddToScheme(scheme.Scheme))

testEnvConfig := helpers.NewTestEnvironmentConfiguration([]string{
path.Join("bootstrap", "eks", "config", "crd", "bases"),
path.Join("config", "crd", "bases"),
},
).WithWebhookConfiguration("unmanaged", path.Join("bootstrap", "eks", "config", "webhook", "manifests.yaml"))
).WithWebhookConfiguration("unmanaged", path.Join("config", "webhook", "manifests.yaml"))
var err error
testEnv, err = testEnvConfig.Build()
if err != nil {
Expand Down
8 changes: 2 additions & 6 deletions bootstrap/eks/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package controllers

import (
"fmt"
"os"
"path"
"testing"

Expand All @@ -37,11 +36,8 @@ var (

func TestMain(m *testing.M) {
setup()
defer func() {
teardown()
}()
code := m.Run()
os.Exit(code) // nolint:gocritic
defer teardown()
m.Run()
}

func setup() {
Expand Down
5 changes: 1 addition & 4 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package controllers

import (
"fmt"
"os"
"path"
"testing"

Expand All @@ -37,11 +36,9 @@ var (
)

func TestMain(m *testing.M) {
code := 0
defer func() { os.Exit(code) }()
setup()
defer teardown()
code = m.Run()
m.Run()
}

func setup() {
Expand Down
7 changes: 2 additions & 5 deletions controlplane/eks/api/v1alpha3/webhook_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package v1alpha3

import (
"fmt"
"os"
"path"
"testing"

Expand All @@ -36,19 +35,17 @@ var (
)

func TestMain(m *testing.M) {
code := 0
defer func() { os.Exit(code) }()
setup()
defer teardown()
code = m.Run()
m.Run()
}

func setup() {
utilruntime.Must(AddToScheme(scheme.Scheme))
utilruntime.Must(controlplanev1alpha4.AddToScheme(scheme.Scheme))

testEnvConfig := helpers.NewTestEnvironmentConfiguration([]string{
path.Join("..", "config", "crd", "bases"),
path.Join("config", "crd", "bases"),
},
).WithWebhookConfiguration("unmanaged", path.Join("config", "webhook", "manifests.yaml"))
var err error
Expand Down
6 changes: 2 additions & 4 deletions controlplane/eks/api/v1alpha4/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package v1alpha4

import (
"fmt"
"os"
"path"
"testing"

Expand All @@ -35,9 +34,8 @@ var (

func TestMain(m *testing.M) {
setup()
code := m.Run()
teardown()
os.Exit(code)
defer teardown()
m.Run()
}

func setup() {
Expand Down
5 changes: 1 addition & 4 deletions exp/api/v1alpha3/webhook_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package v1alpha3

import (
"fmt"
"os"
"path"
"testing"

Expand Down Expand Up @@ -51,11 +50,9 @@ func TestAPIs(t *testing.T) {
}

func TestMain(m *testing.M) {
code := 0
defer func() { os.Exit(code) }()
setup()
defer teardown()
code = m.Run()
m.Run()
}

func setup() {
Expand Down
6 changes: 1 addition & 5 deletions exp/controlleridentitycreator/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package controlleridentitycreator

import (
"fmt"
"os"
"path"
"testing"

Expand All @@ -43,11 +42,9 @@ var (
)

func TestMain(m *testing.M) {
code := 0
defer func() { os.Exit(code) }()
setup()
defer teardown()
code = m.Run()
m.Run()
}

func setup() {
Expand All @@ -57,7 +54,6 @@ func setup() {

testEnvConfig := helpers.NewTestEnvironmentConfiguration([]string{
path.Join("config", "crd", "bases"),
path.Join("controlplane", "eks", "config", "crd", "bases"),
},
).WithWebhookConfiguration("unmanaged", path.Join("config", "webhook", "manifests.yaml"))
var err error
Expand Down
5 changes: 1 addition & 4 deletions exp/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package controllers

import (
"fmt"
"os"
"path"
"testing"

Expand All @@ -42,11 +41,9 @@ var (
)

func TestMain(m *testing.M) {
code := 0
defer func() { os.Exit(code) }()
setup()
defer teardown()
code = m.Run()
m.Run()
}

func setup() {
Expand Down
5 changes: 1 addition & 4 deletions exp/instancestate/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package instancestate

import (
"fmt"
"os"
"path"
"testing"

Expand Down Expand Up @@ -47,11 +46,9 @@ var (
)

func TestMain(m *testing.M) {
code := 0
defer func() { os.Exit(code) }()
setup()
defer teardown()
code = m.Run()
m.Run()
}

func setup() {
Expand Down