The environment variables CK_RUN_SUITE
and CK_RUN_CASE
exists for running specific suites and test cases, respectively. I suggest adding the environment variable CK_RUN_TEST
for running specific test functions. For example:
START_TEST(example_test_name) { /* test code */ } END_TEST
This environment variable would cause only the above test to be run:
CK_RUN_TEST=example_test_name ./test/check_my_project
Since STAR_TEST
is a macro, the name of the test function can be (and probably already is?) saved as a string and could used for this purpose.
As far as I know, not all test functions must have unique names since they could be defined in separate files. In case of ambiguity you could simply fail with the error "Test function name 'example_test_name' is ambiguous"
, leaving it up to the user to select a unique name. Alternatively, you could implement this by adding some syntax to the existing CK_RUN_CASE
variable:
CK_RUN_CASE="case_name:example_test_name" ./test/check_my_project
I really miss this functionality when I locate a bug in my code and I want to explore the circumstances of the bug by adding printf
statements. When selectively running only the relevant test case, that still causes dozens of test functions to get executed, flooding my screen with text from the printf
statements. Being able to only run the specific test function most relevant to the bug would be extremely helpful.
Currently I work around this by going to the test case and commenting out the addition of every irrelevant test function. I do this a lot, and I forget to uncomment the lines far too often.