Skip to content

Commit f2cab0a

Browse files
committed
clar: fix parsing of test suite prefixes
When passing in a specific suite which should be executed by clar via `-stest::suite`, we try to parse this string and then include all tests contained in this suite. This also includes all tests in sub-suites, e.g. 'test::suite::foo'. In the case where multiple suites start with the same _string_, for example 'test::foo' and 'test::foobar', we fail to distinguish this correctly. When passing in `-stest::foobar`, we wrongly determine that 'test::foo' is a prefix and try to execute all of its matching functions. But as no function will now match 'test::foobar', we simply execute nothing. To fix this, we instead have to check if the prefix is an actual suite prefix as opposed to a simple string prefix. We do so by by inspecting if the first two characters trailing the prefix are our suite delimiters '::', and only consider the filter as matching in this case.
1 parent baa87df commit f2cab0a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/clar.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,12 @@ clar_parse_args(int argc, char **argv)
340340
if (strncmp(argument, _clar_suites[j].name, cmplen) == 0) {
341341
int exact = (arglen >= suitelen);
342342

343+
/* Do we have a real suite prefix separated by a
344+
* trailing '::' or just a matching substring? */
345+
if (arglen > suitelen && (argument[suitelen] != ':'
346+
|| argument[suitelen + 1] != ':'))
347+
continue;
348+
343349
++found;
344350

345351
if (!exact)

0 commit comments

Comments
 (0)