Commit 86b85492b1bc8eeb9ff1af25b92877969f17833a

Patrick Steinhardt 2020-06-03T15:40:37

Merge pull request #5537 from libgit2/ethomson/clar_exactmatch tests: offer exact name matching with a `$` suffix

diff --git a/tests/clar.c b/tests/clar.c
index ead13f4..69283b8 100644
--- a/tests/clar.c
+++ b/tests/clar.c
@@ -293,6 +293,7 @@ clar_run_suite(const struct clar_suite *suite, const char *filter)
 	const struct clar_func *test = suite->tests;
 	size_t i, matchlen;
 	struct clar_report *report;
+	int exact = 0;
 
 	if (!suite->enabled)
 		return;
@@ -317,6 +318,11 @@ clar_run_suite(const struct clar_suite *suite, const char *filter)
 			while (*filter == ':')
 				++filter;
 			matchlen = strlen(filter);
+
+			if (matchlen && filter[matchlen - 1] == '$') {
+				exact = 1;
+				matchlen--;
+			}
 		}
 	}
 
@@ -324,6 +330,9 @@ clar_run_suite(const struct clar_suite *suite, const char *filter)
 		if (filter && strncmp(test[i].name, filter, matchlen))
 			continue;
 
+		if (exact && strlen(test[i].name) != matchlen)
+			continue;
+
 		_clar.active_test = test[i].name;
 
 		report = calloc(1, sizeof(struct clar_report));