Skip to content

Commit 86b8549

Browse files
authored
Merge pull request libgit2#5537 from libgit2/ethomson/clar_exactmatch
tests: offer exact name matching with a `$` suffix
2 parents 53a8f46 + 0d3ce2a commit 86b8549

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/clar.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ clar_run_suite(const struct clar_suite *suite, const char *filter)
293293
const struct clar_func *test = suite->tests;
294294
size_t i, matchlen;
295295
struct clar_report *report;
296+
int exact = 0;
296297

297298
if (!suite->enabled)
298299
return;
@@ -317,13 +318,21 @@ clar_run_suite(const struct clar_suite *suite, const char *filter)
317318
while (*filter == ':')
318319
++filter;
319320
matchlen = strlen(filter);
321+
322+
if (matchlen && filter[matchlen - 1] == '$') {
323+
exact = 1;
324+
matchlen--;
325+
}
320326
}
321327
}
322328

323329
for (i = 0; i < suite->test_count; ++i) {
324330
if (filter && strncmp(test[i].name, filter, matchlen))
325331
continue;
326332

333+
if (exact && strlen(test[i].name) != matchlen)
334+
continue;
335+
327336
_clar.active_test = test[i].name;
328337

329338
report = calloc(1, sizeof(struct clar_report));

0 commit comments

Comments
 (0)