-
Notifications
You must be signed in to change notification settings - Fork 143
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
using util.Fatal in a right way #582
Comments
Another issue I found in reviewing #640. |
I've just happened to see this issue, and it's true that a |
So far `util.Fatal()`, which calls `os.Exit(1)`, has been widely used to exit immediately when a critical error happened. Its downside is though that no further function can called after that moment, even defer functions cannot be called. That's fine if there's nothing to clean up or the test is simple enough. Though it could be an issue, for example, when a test should print out TAP output by calling `t.AutoPlan()`, or when it should clean up something. So let's try to use `util.Fatal()` only for errors from critical cases like errors from `util.GetDefaultGenerator()` or `util.PrepareBundle()`. In case of main test errors, use instead `t.Fail(err.Error())` to print out errors in TAP outputs. Partly addresses opencontainers#582 /cc @liangchenye Signed-off-by: Dongsu Park <[email protected]>
So far `util.Fatal()`, which calls `os.Exit(1)`, has been widely used to exit immediately when a critical error happened. Its downside is though that no further function can be called after that moment, even defer functions cannot be called. That's fine if there's nothing to clean up or the test is simple enough. Though it could be an issue, for example, when a test should print out TAP output by calling `t.AutoPlan()`, or when it should clean up something. So let's try to use `util.Fatal()` only for errors from critical cases like errors from `util.GetDefaultGenerator()` or `util.PrepareBundle()`. In case of main test errors, use instead `t.Fail(err.Error())` to print out errors in TAP outputs. Partly addresses opencontainers#582 /cc @liangchenye Signed-off-by: Dongsu Park <[email protected]>
So far `util.Fatal()`, which calls `os.Exit(1)`, has been widely used to exit immediately when a critical error happened. Its downside is though that no further function can be called after that moment, even defer functions cannot be called. That's fine if there's nothing to clean up or the test is simple enough. Though it could be an issue, for example, when a test should print out TAP output by calling `t.AutoPlan()`, or when it should clean up something. So let's try to use `util.Fatal()` only for errors from critical cases like errors from `util.GetDefaultGenerator()` or `util.PrepareBundle()`. In case of main test errors, use instead `t.Fail(err.Error())` to print out errors in TAP outputs. Partly addresses opencontainers#582 /cc @liangchenye Signed-off-by: Dongsu Park <[email protected]>
In some tests, we are using 'util.Fatal'. It exits immediately, so 'defer' functions will not be called.
We will leave the testing bunde dir or a container.
It needs to be fixed.
The text was updated successfully, but these errors were encountered: