Add simpler method for test generation#266
Conversation
While generating test code for C and C++, I found that manually specifying WordLocations was quite tedious. It made it challenging to add new test cases when testing new language features. To simplify this process, this commit adds the `get_marked_misspellings()` function, which takes in an input string where all expected misspellings are marked using start/end delimiters. The function returns a struct containing: 1. The input string with the delimiters removed. 2. All of the marked misspellings. You can use this function to quickly test lots of functionality using simple-to-create input files.
Word locations are not deterministically ordered, so we need to sort them before comparing the sequences for equality.
|
Wasn't sure what you thought of this approach, but I think it makes writing tests a bit easier. Let me know if you have any suggestions! |
|
Hey! Thanks for the query fixes, nice work. If you'd like to get those in faster, please do a separate PR. I'll need some more time to evaluate the test infra changes. In general, I try to make testing code more duplication heavy than core code, since I try to avoid having to write tests for tests :) That being said, there are certainly emerging testing patterns that could be extracted to help people write more consistent cases. |
|
Hey! I've dramatically simplified testing by extracting a few utilities. Check out #292 if you're interested. This removes a few hundred lines of tests, so I think this will get us pretty far for now. Thanks for the nudge! |
While generating test code for C and C++, I found that manually specifying WordLocations was quite tedious. It made it challenging to add new test cases when testing new language features.
To simplify this process, this commit adds the
get_marked_misspellings()function, which takes in an input string where all expected misspellings are marked using start/end delimiters. The function returns a struct containing:You can use this function to quickly test lots of functionality using simple-to-create input files.
As an example, I converted the C-language tests to use this new functionality. As a result of the testing, I identified and fixed a bug related to enum, struct, and union specifiers. Previously, codebook would flag
Structt,EnummandUnionnin the following code snippet: