-
Notifications
You must be signed in to change notification settings - Fork 3.6k
commonize tester arguments in a single location #7724
Conversation
& don't allow unknown arguments
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 might be some other arguably better ways like moving the static variable to a global test fixture or something... if someone really wants to push for that we could do it.
I'll push for it, because:
🚨🚨This will break eosio.contracts because this initialization code was copy pasted there a third time so there will be a duplicate symbol when linking with tester library. Not sure how to best handle that.
Moving the initialization code to a global fixture would fix this. It'll leave the initialization code running twice in cdt until cdt is updated, but I think that's harmless.
I think better than a global fixture (which will be built and torn down a lot) we should use BOOST_TEST_GLOBAL_CONFIGURATION Its not well documented but it is what Boost::Test uses to initialize its logging etc. The pro is that its guaranteed to be once per invocation. |
I think, if we are going for a more complete solution we should consider a few things: is this still enabling?:
do we have tests that depend on Can we separate the needs of Related to that, is it appropriate to have a command line switch for the wasm backend selector OR is there a way to work this into the unit tests explicitly via something like |
The wasm_backend is a runtime parameter, so Data driven test cases would be more appropriate than |
I don't know enough about data driven testing in boost however, I suspect there will be times when people want to run a full battery of tests on only a single backend. The command line argument was nice for that and integrating it into the test cases such that you can filter by a backend would have maintained that capability. Is there a convenient way to do that with the data driven tests? |
The only use of |
You can choose tests by name, and the data is appended to the test case name, so:
|
Never mind, that's not right. |
Those seem easily replaced with explicit pairwise swaps. We just want a the resulting schedule to be different than the current schedule. Each successive schedule could just ping/pong back and forth. For instance, each time |
I think |
For |
Nope, it seems it is not possible to "rename" the dataset's naming of each test. So it would always be named foo/_0 and foo/_1, so there would be no way to enable/disable all test for a runtime via a name that way. We could make the dataset dynamically change its indexes based on the command line. |
How about |
I don't have any major issue with it. Minor issue is it seems like overkill but I agree that the intent of the code is more legible than the |
seems like |
In a world with no perfect solutions, I think I'd prefer to keep fixture support and solve this through one of the other options. If that means we are still parsing "extra" options after the standard boost options with some global or fixture or configuration then so be it. |
|
considering that it was added 10 years ago it probably just is sloppy documentation then |
The template mechanism looked really promising, something like: BOOST_FIXTURE_TEST_CASE_TEMPLATE( my_test, T, wasm_runtimes, tester<T> )
{
dothedew();
} but unfortunately this doesn't work because of dependent name lookups. Has to be more like BOOST_FIXTURE_TEST_CASE_TEMPLATE( my_test, T, wasm_runtimes, tester<T> )
{
this->dothedew();
} which of course drastically reduces the usefulness of the fixture. So unfortunately it seems like we will have make something more custom |
I put together a prototype of a custom test case a few days ago. |
Change Description
When running unittests there are some optional arguments that can be given like
--verbose
or--(name of wasm runtime)
. There are some glaring problems with the current approach: the code is duplicated (actually triplicated, as I'll get to in a moment), arguments are handled at different locations, and unknown arguments are silently ignored.The last one is a nasty gotcha. If you try running the unit tests with
--wovm
thinking you were going to run the unit tests with the WAVM runtime the code will silently ignore that unknown argument and run the tests with the default runtime instead. This can be incredibly deceptive.This PR seeks the resolve all the above issues. I'm not thrilled about having to set a static member in base_tester now but it's a considerable step up from where we were IMO. There might be some other arguably better ways like moving the static variable to a global test fixture or something... if someone really wants to push for that we could do it.
🚨🚨This will break eosio.contracts because this initialization code was copy pastaed there a third time so there will be a duplicate symbol when linking with tester library. Not sure how to best handle that.
Consensus Changes
API Changes
Documentation Additions