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

validation: use t.Fail when checking for main test errors #645

Merged

Conversation

dongsupark
Copy link
Contributor

@dongsupark dongsupark commented 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 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 #582

/cc @liangchenye

Signed-off-by: Dongsu Park dongsu@kinvolk.io

@zhouhao3
Copy link

zhouhao3 commented Jun 6, 2018

The same content in start.go needs to be modified.

@dongsupark
Copy link
Contributor Author

@q384566678 Done. Updated start.go as well.

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 <dongsu@kinvolk.io>
@dongsupark
Copy link
Contributor Author

Rebased.

@zhouhao3
Copy link

zhouhao3 commented Jul 2, 2018

LGTM

Approved with PullApprove

@zhouhao3 zhouhao3 merged commit 05b5772 into opencontainers:master Jul 2, 2018
@dongsupark dongsupark deleted the dongsu/correct-fail-func branch July 2, 2018 08:26
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

Successfully merging this pull request may close these issues.

2 participants