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

using util.Fatal in a right way #582

Open
liangchenye opened this issue Feb 13, 2018 · 3 comments
Open

using util.Fatal in a right way #582

liangchenye opened this issue Feb 13, 2018 · 3 comments

Comments

@liangchenye
Copy link
Member

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.

@liangchenye
Copy link
Member Author

Another issue I found in reviewing #640.
We need a patch to make RuntimeInsideValidate and RuntimeOutsideValidate stronger.
Now it does not different runtime error and runtime-tool/system error.

@dongsupark
Copy link
Contributor

I've just happened to see this issue, and it's true that a defer function does not run when util.Fatal is called. So far I have been also making such mistakes.
I agree that we should fix it, although there are many places to touch.

dongsupark pushed a commit to kinvolk-archives/runtime-tools that referenced this issue Jun 1, 2018
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]>
dongsupark pushed a commit to kinvolk-archives/runtime-tools that referenced this issue Jun 8, 2018
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]>
dongsupark pushed a commit to kinvolk-archives/runtime-tools that referenced this issue Jun 28, 2018
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]>
@dongsupark
Copy link
Contributor

If I understand correctly, this issue can be closed now.
The original issue, using util.Fatal correctly, was addressed by #645.
The second issue, differentiation of runtime-tools TAP errors and system errors was done by #658.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants