Support multiple test suites and add helpful verifiers#18
Conversation
No cmd-line support yet to indicate suites to run
|
My apologies for the delay in creating this PR. I was first delayed by a meeting that went long. I was then sucked in by an "unhandled exception" and an issue with the new function template |
|
Everything looks great! here is my question:
I will continue to review this PR tomorrow. |
|
Thanks @cmcmone for the review:
Good point. I am not sure why I used map instead of unordered map. I will weigh the pros and cons.
I thought about this quite a bit when implementing it, but decided not to test because there are many conditions under which a non-empty input can still result in an empty list of suites to run and it is not clear if "run all suites" should be true only if the input string is empty. What if the string is
Quite possible: old habit 😢. Also, initial values that from long/complex expressions are traditionally written with assignment. Regardless, it will be helpful to use in-situ comment and the "suggest" feature and point out the locations where UIS is missed. I too will look for them.
Possibly. I'll look into it. |
|
I just pushed changes with variable-renaming and comment edits I made during the call earlier this afternoon. I also added checks for duplicate test-suite name and other errors when adding a test suite. |
|
I just pushed the following two changes:
I expect these to be the last changes I expect to initiate on this PR. Of course, I'll address issues you report. I would appreciate being able to close this PR tonight. Thank you for your assistance. |
There was a problem hiding this comment.
I tested and everything looks great. Thank you @smurthys @Ndemco @Ajetski for your contributions.
A little personal thought may not be within the scope of this PR.
- Is it more visual to print a table? (add an option to print the table)
| name | completed | passed | failed |
|---|---|---|---|
| array_test | 32 | 32 | 0 |
| Total | 32 | 32 | 0 |
- If the parameter input is similar to
-run array_test; string_test, the exception throw isincorrect number of options, but I think to throw an exception likewrong run commandis more appropriate.
|
Thanks @cmcmone for your review. It will be nice to format test summary as a table, and you are right that that task is not related to this PR or milestone. I recommend creating an issue so we can prioritize and track. Any cmd-line parameter containing a has a space needs to be quoted if that item has to be treated as one value. This is an OS requirement. So, the OS considers the cmd-line That said, as far as the A solution would be to trim leading and trailing spaces before looking up suite names in the collection, but I worry about spending valuable resources (time) on addressing extreme/unlikely cases. However, I also think it is unwise to not document or handle this issue at an appropriate time. I propose you add an issue describing this problem and link to this (my) comment. |
|
I updated the cmd-line documentation to account for the notion of suites. It turned out to be lot of changes. 😮 BTW, I'm not happy with the background of the image at the start of the doc. I don't know why the background has a grid, but I am not able to attend to that at this moment. I welcome others to give it a shot. EDIT: I am attaching the PPT file I used to generate the image containing the annotated example, in case someone wants to experiment. |
@smurthys I don’t quite understand, I don’t see any grid. 😕 |
|
Compare the gray background in the image (the one with annotations) with the background in the Examples section. The background in the examples are smooth, whereas the background in the image is not as smooth. I believe the image's background was much smoother in the previous version, and @Ndemco had created that image. Clearly, I'm doing something wrong in how I created the image. All this said, the image background is not a big issue. I am willing to live with it, at least for now. |
|
@smurthys like this? |
|
Yes @cmcmone. The image you show does have a smooth background even with the annotations. |
|
Thanks @cmcmone. I'll try it next time. In the meantime, I used the image you shared in your earlier comment. |


This PR adds support for multiple test suites (goal of M4) and also adds helpful verifiers. I welcome your review. Here is a summary of changes:
Support for multiple test suites:
void f(), wherefwould be the name of a suite runner.array_testinarray-test.cppis an actual suite runner.run_suitesindriver.cppsets up the tester for each suite and invokes test suites. See the comment associated with thestd::mapvariablesuitesfor a brief on how to specify the available "suite runners". Also see the comment just preceding the function about declaring suite runners. The specification of suite runners could possibly be better, but I feel the current state suffices for this PR.-runcmd-line option to specify the subset of test suites to run. The value of this option is a semi-colon separated list of suite names to run. This option will be quite helpful during the development of a test suite.$suiteto stand for suite name. At present the macro expansion is done only in header text. The next round of changes might support expanding this macro also in the fileRunning $suitefromRunning $cmdutils.handutils.cppto hold truly general-purpose functions such asreplace_alland the newly added function templatesplit. The function template and its unit tests are at https://godbolt.org/z/LfPFVH. (EDIT: updated link with additional test cases)Changes to tester:
New helpful verifiers:
is_true,is_false,is_zero,is_nonzero,is_negative,is_nonnegative,is_positive,verifyin array_test with is_true only for illustration. Using the helpers in that test suite is not part of this PR.verifyshould not be called directly, but that call is not prevented: nothing really wrong in calling it, but using the helpers makes tests simpler and somewhat self-documenting.