-
Notifications
You must be signed in to change notification settings - Fork 410
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
dynamic test registration #349
dynamic test registration #349
Conversation
f8841de
to
6a11800
Compare
2a762fb
to
c04077b
Compare
fc67b65
to
f1c0361
Compare
If i understand the code correctly, this basically allows you to define functions: function assert_equals {
if [[ "$1" != "$2" ]]; then
echo "[$1] != [$2]"
fi
} Which can be run at any point later by invoking a another function: bats_test_function --description "one is one" assert_equals "one" "one"
bats_test_function --description "two is two" assert_equals "two" "two"
bats_test_function --description "two is three" assert_equals "two" "three" Then you would see a single set of results: ✓ one is one
✓ two is two
✗ two is three
(from function `assert_equals' in file tests.bats, line ?)
`?' failed
3 tests, 1 failure This seems sufficiently dynamic for most use cases. When you say
is that just to say that bats will be less helpful in pointing out where your syntax errors are? or that things might not actually work because your tests have vars that collide with bats internals? |
The main problem is: when we hook code into bats, it might mess with internal variables. Additionally, if there is a syntax error in the sourced file, bats will go down with it, potentially swallowing the error (or giving unhelpful filenames due to the preprocessing). I am thinking about jailing this |
Add a test case that incrementally scales up a cluster from 1 to 4 nodes, (re-)running the cluster tests after each scaling event. To work around the fact that bats-core does currently not provide any way of programmatically composing tests, we use the workaround provided in bats-core/bats-core#241. Essentially we use a bats test definition file as a wrapper to invoke tests from a different bats test definition file. Note that the outer bats runner will perform validation on the number of tests ran based on TAP output, so it is important that the inner bats runner uses a different format for its output. We should monitor the progress of bats-core/bats-core#349 and move to something like that when it materializes. Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
9e00e86
to
8f27554
Compare
This ensure we detect when a change disables Bats from reporting failures. This would not be detectable by Bats' selftests.
- simplify stack trace limiting
8f27554
to
9d5ecdb
Compare
4f7f83c
to
4070284
Compare
due to unbound variable BATS_BEGIN_CODE_QUOTE
4070284
to
23e174f
Compare
Any thoughts in this @brokenpip3 ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I happened to notice something while reading the code:
_bats_test_functions_setup -1 # invalid TEST_NUMBER, as this is not a test | ||
|
||
BATS_TEST_NAME=source | ||
BATS_TEST_FILTER="$BATS_TEST_FILTER" bats_preprocess_source # uses BATS_TEST_FILENAME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There doesn't seem to be anything left that's using BATS_TEST_FILTER
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to remove BATS_TEST_FILTER
in #907
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This broke test suites with multiple files loading common constants. I have tried to put together a possible fix with test cases to illustrate the problem in #904
I played a bit around with the framework to see if we could get parametrized tests working, so this is more of a proof of concept.
This needs #348 but I wanted to make those separate so we can play around here.
I see the following issues with this PR:
source
ing the test file, there is even more collision surface between tests and the framework, this becomes especially nasty when there are syntax errors in the test filesCloses #306