-
Notifications
You must be signed in to change notification settings - Fork 34
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
RFC: rlAssert terminate test script immediately #42
Comments
Such behaviour should not be hard to implement. However what about Cleanup? If you exited the test after first failed assert (for example by calling rlPhaseEnd; rlJournalEnd) but the test would just end and there would be no cleanup after. Is this fine by you? btw we are beakerlib developers, not beaker developers :) |
Just my $.02; what I'd normally do is create
then you can call this as
of course you might want to put much less or much more in the fail handler; depending on your situation. If you need to avoid touching your current test code, then you could do this eg. by injecting own beakerlib.sh that overloads all original functions:
|
Simple |
If you want to limit it just to all asserts (everything what generates |
Well problem with Problem with I don't know anything about |
Beakerlib upstream can't do this yet, but might at some point: beakerlib/beakerlib#42 This is only enabled in combination with the `--sit` option of the `test/check-*` scripts. It leaves the system in exacly the state it was in when an assertion failed. Finishing the test run would run cleanup as well (such as deleting created images). It also takes longer.
Beakerlib upstream can't do this yet, but might at some point: beakerlib/beakerlib#42 This is only enabled in combination with the `--sit` option of the `test/check-*` scripts. It leaves the system in exacly the state it was in when an assertion failed. Finishing the test run would run cleanup as well (such as deleting created images). It also takes longer.
Thanks for these ideas! I've tried monkey-patching Except of course that it will fail when beakerlib changes. I'd really like to see something like this as a proper feature. Would you be interested in that? Some context: when debugging a test failure, it's really useful to have a machine stay in exactly the state it's in when the |
I sympathise with the importance of preserving the state. But:
Hence I would not support this on Beakerlib level; I'd rather see another library around it that helps with test code flow, which is cleaner and much more powerful. (BTW, is |
Indeed, but I'd have to wrap every function that might fail. If I miss one or beakerlib adds new ones in the future, my tests will break in subtle ways.
Fair enough. I didn't know beakerlib supports running like this. That makes having such a feature effectively impossible.
We're running the test script through ssh on a virtual machine. The surrounding harness leaves the machine running when the test script exits with non-0. Good idea about preserving the environment. We'd need to find a way to signal that that's the state the script is in, but it's definitely something to think about. Thanks! Feel free to close this bug. |
Beakerlib upstream can't do this yet, but might at some point: beakerlib/beakerlib#42 This is only enabled in combination with the `--sit` option of the `test/check-*` scripts. It leaves the system in exacly the state it was in when an assertion failed. Finishing the test run would run cleanup as well (such as deleting created images). It also takes longer.
Beakerlib upstream can't do this yet, but might at some point: beakerlib/beakerlib#42 This is only enabled in combination with the `--sit` option of the `test/check-*` scripts. It leaves the system in exacly the state it was in when an assertion failed. Finishing the test run would run cleanup as well (such as deleting created images). It also takes longer.
Beakerlib upstream can't do this yet, but might at some point: beakerlib/beakerlib#42 This is only enabled in combination with the `--sit` option of the `test/check-*` scripts. It leaves the system in exacly the state it was in when an assertion failed. Finishing the test run would run cleanup as well (such as deleting created images). It also takes longer.
Only if your tests use the new functions.
I'm not myself so strictly against this feature; I see the usefulness. To summarize my argument: what you want is flow control, while most core features in BeakerLib are about logging and setup/cleanup (plus some fact collecton utilities on top); so I would be careful of trying to extend it that direction (esp. if it might not be so reliable after all). |
As mentioned above. Beakerlib cannot reliably catch all the possibilities. Thus direct support does not make sense. To be more user friendly and allow user to better handle it on the user's side I would be willing to make some public function similar to |
@larskarlitski if you are still interested in this feature, please propose a PR. As a control variable I would propose Otherwise I'm going to close this issue. |
Thanks for coming back to this. I don't have an immediate need for it at the moment. |
Hello beaker-devs,
in lorax-composer we would like to have
rlAssert
statements (and anything else that can report FAIL really) to terminate the test script immediately. It is fine with us if this is not enabled by default but we need some way to make it happen.Can you point me in the right direction? Where do I look internally in beakerlib to see if we can hack something up? Ideally an ENV variable or a config file will work great.
CC @larskarlitski
The text was updated successfully, but these errors were encountered: