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

After panic recovery and performing of finish steps tests are not marked as failed #328

Closed
StupidScience opened this issue Oct 7, 2023 · 2 comments · Fixed by #342
Closed
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@StupidScience
Copy link

What happened?

After panic recovery and performing of finish steps tests are not marked as failed

What did you expect to happen?

After panic I expect tests to be marked as failed ones

How can we reproduce it (as minimally and precisely as possible)?

func TestMain(m *testing.M) {
	testEnv := env.New()
	testEnv.Setup(
		causePanic(),
	)

	os.Exit(testEnv.Run(m))
}

func causePanic() env.Func {
	return func(ctx context.Context, config *envconf.Config) (context.Context, error) {
		panic("aaaaa")

		return ctx, nil
	}
}

this code will cause panic and recover but exit code of go test command will be 0 and tests will be reported as ok

Anything elese we need to know?

No response

E2E Provider Used

kind

e2e-framework Version

0.3.0

OS version

any

@StupidScience StupidScience added the kind/bug Categorizes issue or PR as related to a bug. label Oct 7, 2023
@harshanarayana
Copy link
Contributor

@StupidScience This is a nice catch. Thanks for bug report.

❯ go test -v .
E1026 17:27:03.045149   58234 env.go:361] Recovering from panic and running finish actions: aaaaa, stack: goroutine 1 [running]:
runtime/debug.Stack()
	/Users/harshnar/.gvm/gos/go1.19/src/runtime/debug/stack.go:24 +0x65
sigs.k8s.io/e2e-framework/pkg/env.(*testEnv).Run.func1()
	/Users/harshnar/Work/Tesseract/Maglev/mks/k8s/e2e-framework/pkg/env/env.go:361 +0x9b
panic({0x2075d40, 0x24d1f30})
	/Users/harshnar/.gvm/gos/go1.19/src/runtime/panic.go:884 +0x212
sigs.k8s.io/e2e-framework/examples/panictest.TestMain.func1({0xc000171c98?, 0x1050e74?}, 0x50?)
	/Users/harshnar/Work/Tesseract/Maglev/mks/k8s/e2e-framework/examples/panictest/main_test.go:23 +0x27
sigs.k8s.io/e2e-framework/pkg/env.(*action).run(0x21972e0?, {0x24ea050?, 0xc000128008?}, 0xc00048c800)
	/Users/harshnar/Work/Tesseract/Maglev/mks/k8s/e2e-framework/pkg/env/action.go:135 +0xea
sigs.k8s.io/e2e-framework/pkg/env.(*testEnv).Run(0xc000171e88, 0xc0004a86b0?)
	/Users/harshnar/Work/Tesseract/Maglev/mks/k8s/e2e-framework/pkg/env/env.go:379 +0x217
sigs.k8s.io/e2e-framework/examples/panictest.TestMain(0xffffffffffffffff?)
	/Users/harshnar/Work/Tesseract/Maglev/mks/k8s/e2e-framework/examples/panictest/main_test.go:18 +0x9d
main.main()
	_testmain.go:49 +0x1d3
FAIL	sigs.k8s.io/e2e-framework/examples/panictest	1.420s
FAIL

I believe this is what you are expecting to happen ?

@StupidScience
Copy link
Author

@harshanarayana hard to tell but on first sight looks correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants