Test Runner support for Dynamic Tests #5488
Replies: 2 comments 4 replies
-
Am I understanding correctly that this is essentially an API for threading test-cases? I'm reading it as if you're able to wrap what used to be the body of a loop with something and now the inner test case of that loop is treated as many test cases which run concurrently. |
Beta Was this translation helpful? Give feedback.
-
This is not a problem. Turning one test which runs well into 6,000 tests which compete for all of the cores of the machine while shuffling the same data between caches when it could instead be focused in one spot is not a good idea.
This is false. The only difference between your proposal and now is that the test vectors would be given their own thread.
Correct. The situation as it is now is optimal for the case you have outlined as a problem. If you need automated subdivisions of tests (i.e.
If this is something you truly want, there is nothing stopping you from maintaining your own test runner, but as it stands, I am not welcoming the added complexity for what is yet to be illustrated to me as a problem. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem Background
I'm a big fan of testing and ease of writing tests. A lot of times, several test cases share the same logic and differ only in the inputs and expected outputs. In fact, this is a current problem with the compiler tests as can be seen by the Unicode tests declaring a
run_test_cases
procedure (Approach A) or the Python script that generates tests for themath/big
module (Approach B).Approach A is the simplistic approach to the concept of "parameterized tests". It is easy to write and execute, with each set of inputs and outputs being considered a different test case. However, this approach does not take advantage of the test runner to execute such test cases so any guarantees, features and improvements to the test runner aren't used. This might mean threading support (e.g. if there are 1000 parameterized test cases then they all execute as a single test case in the runner, instead of the actual 1000 test cases that they are), error/panic handling, etc.
Approach B is the purest implementation of the concept of "dynamic tests". Test code is generated and then integrated into the regular test runner execution as if it existed all along. However, this approach is quite complex (in this case it involves a whole other programming language) as well as having several pitfalls: it is easy to forget to re-run the generation script, the build system now needs extra tooling for building the project, extra resources need to be maintained which might require collaborators to learn new languages or delegate the changes to someone else, etc.
Proposed Solution
The
core:testing
module could be extended to support submission of dynamic tests at runtime. This would allow users to rely on both the concepts of "dynamic tests" as well as "parameterized tests" (which build on top of the former). Since the dynamic tests would need to be submitted at runtime, the user has the option to:The main point here is that the developer has full control on how much or how little to rely on the runtime submission of dynamic tests, while opening up a whole breadth of potential testing power by using the technology that they are already familiar with: Odin. And for users that do not use this feature entirely there would be no impact to their regular testing workflow.
Additional Notes
This is something I have wanted for a long time so I played around with implementing it on my local machine, and to my surprise it was much simpler than I originally expected. It obviously isn't the quality required for integration with the code base (e.g. I haven't cleaned up the changes to remove code duplication, naming improvements, etc.) and I don't have the means to validate that it works across all targets, but it works as a proof of concept. I'm including the git patch here as a code reference to what I am proposing.
Dynamic Test Support Patch - PoC
Beta Was this translation helpful? Give feedback.
All reactions