summaryrefslogtreecommitdiff
path: root/tests-clar/clar.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-06-10 10:10:39 -0700
committerRussell Belfer <rb@github.com>2013-06-10 10:10:39 -0700
commit114f5a6c41ea03393e00ae41126a6ddb0ef39a15 (patch)
treef579e849a72749123a54483180726396244177b2 /tests-clar/clar.c
parent7000f3fa7bad25ec07355d6afb640ea272201dff (diff)
downloadlibgit2-114f5a6c41ea03393e00ae41126a6ddb0ef39a15.tar.gz
Reorganize diff and add basic diff driver
This is a significant reorganization of the diff code to break it into a set of more clearly distinct files and to document the new organization. Hopefully this will make the diff code easier to understand and to extend. This adds a new `git_diff_driver` object that looks of diff driver information from the attributes and the config so that things like function content in diff headers can be provided. The full driver spec is not implemented in the commit - this is focused on the reorganization of the code and putting the driver hooks in place. This also removes a few #includes from src/repository.h that were overbroad, but as a result required extra #includes in a variety of places since including src/repository.h no longer results in pulling in the whole world.
Diffstat (limited to 'tests-clar/clar.c')
-rw-r--r--tests-clar/clar.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/tests-clar/clar.c b/tests-clar/clar.c
index fed87c30d..0eae81bf5 100644
--- a/tests-clar/clar.c
+++ b/tests-clar/clar.c
@@ -183,10 +183,10 @@ clar_run_test(
}
static void
-clar_run_suite(const struct clar_suite *suite)
+clar_run_suite(const struct clar_suite *suite, const char *name)
{
const struct clar_func *test = suite->tests;
- size_t i;
+ size_t i, namelen;
if (!suite->enabled)
return;
@@ -200,7 +200,23 @@ clar_run_suite(const struct clar_suite *suite)
_clar.active_suite = suite->name;
_clar.suite_errors = 0;
+ if (name) {
+ size_t suitelen = strlen(suite->name);
+ namelen = strlen(name);
+ if (namelen <= suitelen) {
+ name = NULL;
+ } else {
+ name += suitelen;
+ while (*name == ':')
+ ++name;
+ namelen = strlen(name);
+ }
+ }
+
for (i = 0; i < suite->test_count; ++i) {
+ if (name && strncmp(test[i].name, name, namelen))
+ continue;
+
_clar.active_test = test[i].name;
clar_run_test(&test[i], &suite->initialize, &suite->cleanup);
@@ -240,7 +256,7 @@ clar_parse_args(int argc, char **argv)
case 'x': { /* given suite name */
int offset = (argument[2] == '=') ? 3 : 2, found = 0;
char action = argument[1];
- size_t j, len;
+ size_t j, len, cmplen;
argument += offset;
len = strlen(argument);
@@ -249,7 +265,11 @@ clar_parse_args(int argc, char **argv)
clar_usage(argv[0]);
for (j = 0; j < _clar_suite_count; ++j) {
- if (strncmp(argument, _clar_suites[j].name, len) == 0) {
+ cmplen = strlen(_clar_suites[j].name);
+ if (cmplen > len)
+ cmplen = len;
+
+ if (strncmp(argument, _clar_suites[j].name, cmplen) == 0) {
int exact = !strcmp(argument, _clar_suites[j].name);
++found;
@@ -258,9 +278,9 @@ clar_parse_args(int argc, char **argv)
_clar.report_suite_names = 1;
switch (action) {
- case 's': clar_run_suite(&_clar_suites[j]); break;
- case 'i': _clar_suites[j].enabled = 1; break;
- case 'x': _clar_suites[j].enabled = 0; break;
+ case 's': clar_run_suite(&_clar_suites[j], argument); break;
+ case 'i': _clar_suites[j].enabled = 1; break;
+ case 'x': _clar_suites[j].enabled = 0; break;
}
if (exact)
@@ -318,7 +338,7 @@ clar_test(int argc, char **argv)
if (!_clar.suites_ran) {
size_t i;
for (i = 0; i < _clar_suite_count; ++i)
- clar_run_suite(&_clar_suites[i]);
+ clar_run_suite(&_clar_suites[i], NULL);
}
clar_print_shutdown(