summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2016-08-04 11:49:39 +0200
committerPatrick Steinhardt <ps@pks.im>2016-08-04 11:49:39 +0200
commitf2cab0a6faafbeb80e6d12b8a5a18a0185a5280a (patch)
treec850e970e9dd7d4fcf5cd1feeca5c163b1227fdc
parentbaa87dfc5033364ab5ac71099725f8f6c3e6361c (diff)
downloadlibgit2-f2cab0a6faafbeb80e6d12b8a5a18a0185a5280a.tar.gz
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.
-rw-r--r--tests/clar.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/clar.c b/tests/clar.c
index 4bee9f755..905d67db7 100644
--- a/tests/clar.c
+++ b/tests/clar.c
@@ -340,6 +340,12 @@ clar_parse_args(int argc, char **argv)
if (strncmp(argument, _clar_suites[j].name, cmplen) == 0) {
int exact = (arglen >= suitelen);
+ /* Do we have a real suite prefix separated by a
+ * trailing '::' or just a matching substring? */
+ if (arglen > suitelen && (argument[suitelen] != ':'
+ || argument[suitelen + 1] != ':'))
+ continue;
+
++found;
if (!exact)