diff options
| -rw-r--r-- | src/signature.c | 4 | ||||
| -rw-r--r-- | tests-clar/clar.c | 34 | ||||
| -rw-r--r-- | tests-clar/clar.h | 6 | ||||
| -rw-r--r-- | tests-clar/clar/print.h | 5 | ||||
| -rw-r--r-- | tests-clar/commit/parse.c | 8 | ||||
| -rw-r--r-- | tests-clar/generate.py | 33 |
6 files changed, 64 insertions, 26 deletions
diff --git a/src/signature.c b/src/signature.c index d77655315..3380097ff 100644 --- a/src/signature.c +++ b/src/signature.c @@ -241,15 +241,15 @@ static const char *scan_for_previous_token(const char *buffer, const char *left_ static int parse_time(git_time_t *time_out, const char *buffer) { - int time; int error; + int64_t time; if (*buffer == '+' || *buffer == '-') { giterr_set(GITERR_INVALID, "Failed while parsing time. '%s' actually looks like a timezone offset.", buffer); return -1; } - error = git__strtol32(&time, buffer, &buffer, 10); + error = git__strtol64(&time, buffer, &buffer, 10); if (!error) *time_out = (git_time_t)time; diff --git a/tests-clar/clar.c b/tests-clar/clar.c index a7d8d30d0..10bea8724 100644 --- a/tests-clar/clar.c +++ b/tests-clar/clar.c @@ -1,3 +1,9 @@ +/* + * Copyright (c) Vicent Marti. All rights reserved. + * + * This file is part of clar, distributed under the ISC license. + * For full terms see the included COPYING file. + */ #include <assert.h> #include <setjmp.h> #include <stdlib.h> @@ -75,6 +81,7 @@ static struct { int report_errors_only; int exit_on_error; + int report_suite_names; struct clar_error *errors; struct clar_error *last_error; @@ -207,12 +214,12 @@ clar_usage(const char *arg) { printf("Usage: %s [options]\n\n", arg); printf("Options:\n"); - printf(" -sname\t\tRun only the suite with `name`\n"); - printf(" -iname\t\tInclude the suite with `name`\n"); - printf(" -xname\t\tExclude the suite with `name`\n"); - printf(" -q \t\tOnly report tests that had an error\n"); - printf(" -Q \t\tQuit as soon as a test fails\n"); - printf(" -l \t\tPrint suite names\n"); + printf(" -sname\tRun only the suite with `name`\n"); + printf(" -iname\tInclude the suite with `name`\n"); + printf(" -xname\tExclude the suite with `name`\n"); + printf(" -q \tOnly report tests that had an error\n"); + printf(" -Q \tQuit as soon as a test fails\n"); + printf(" -l \tPrint suite names\n"); exit(-1); } @@ -231,7 +238,7 @@ clar_parse_args(int argc, char **argv) case 's': case 'i': case 'x': { /* given suite name */ - int offset = (argument[2] == '=') ? 3 : 2; + int offset = (argument[2] == '=') ? 3 : 2, found = 0; char action = argument[1]; size_t j, len; @@ -243,16 +250,25 @@ clar_parse_args(int argc, char **argv) for (j = 0; j < _clar_suite_count; ++j) { if (strncmp(argument, _clar_suites[j].name, len) == 0) { + int exact = !strcmp(argument, _clar_suites[j].name); + + ++found; + + if (!exact) + _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; } - break; + + if (exact) + break; } } - if (j == _clar_suite_count) { + if (!found) { clar_print_onabort("No suite matching '%s' found.\n", argument); exit(-1); } diff --git a/tests-clar/clar.h b/tests-clar/clar.h index 825874116..2ba6416b3 100644 --- a/tests-clar/clar.h +++ b/tests-clar/clar.h @@ -1,3 +1,9 @@ +/* + * Copyright (c) Vicent Marti. All rights reserved. + * + * This file is part of clar, distributed under the ISC license. + * For full terms see the included COPYING file. + */ #ifndef __CLAR_TEST_H__ #define __CLAR_TEST_H__ diff --git a/tests-clar/clar/print.h b/tests-clar/clar/print.h index db9da9198..368016f2f 100644 --- a/tests-clar/clar/print.h +++ b/tests-clar/clar/print.h @@ -45,9 +45,10 @@ static void clar_print_ontest(const char *test_name, int test_number, int failed static void clar_print_onsuite(const char *suite_name, int suite_index) { - /* noop */ + if (_clar.report_suite_names) + printf("\n%s", suite_name); + (void)suite_index; - (void)suite_name; } static void clar_print_onabort(const char *msg, ...) diff --git a/tests-clar/commit/parse.c b/tests-clar/commit/parse.c index 908d9fba8..1ef2bfe2b 100644 --- a/tests-clar/commit/parse.c +++ b/tests-clar/commit/parse.c @@ -121,6 +121,14 @@ passing_signature_test_case passing_signature_cases[] = { {"author A U Thor <author@example.com> and others 1234567890 -0700\n", "author ", "A U Thor", "author@example.com", 1234567890, -420}, {"author A U Thor <author@example.com> and others 1234567890\n", "author ", "A U Thor", "author@example.com", 1234567890, 0}, {"author A U Thor> <author@example.com> and others 1234567890\n", "author ", "A U Thor>", "author@example.com", 1234567890, 0}, + /* a variety of dates */ + {"author Vicent Marti <tanoku@gmail.com> 0 \n", "author ", "Vicent Marti", "tanoku@gmail.com", 0, 0}, + {"author Vicent Marti <tanoku@gmail.com> 1234567890 \n", "author ", "Vicent Marti", "tanoku@gmail.com", 1234567890, 0}, + {"author Vicent Marti <tanoku@gmail.com> 2147483647 \n", "author ", "Vicent Marti", "tanoku@gmail.com", 0x7fffffff, 0}, + {"author Vicent Marti <tanoku@gmail.com> 4294967295 \n", "author ", "Vicent Marti", "tanoku@gmail.com", 0xffffffff, 0}, + {"author Vicent Marti <tanoku@gmail.com> 4294967296 \n", "author ", "Vicent Marti", "tanoku@gmail.com", 4294967296, 0}, + {"author Vicent Marti <tanoku@gmail.com> 8589934592 \n", "author ", "Vicent Marti", "tanoku@gmail.com", 8589934592, 0}, + {NULL,NULL,NULL,NULL,0,0} }; diff --git a/tests-clar/generate.py b/tests-clar/generate.py index 9d5c117f3..1c96f9b68 100644 --- a/tests-clar/generate.py +++ b/tests-clar/generate.py @@ -1,4 +1,10 @@ #!/usr/bin/env python +# +# Copyright (c) Vicent Marti. All rights reserved. +# +# This file is part of clar, distributed under the ISC license. +# For full terms see the included COPYING file. +# from __future__ import with_statement from string import Template @@ -11,12 +17,12 @@ class Module(object): def _render_callback(self, cb): if not cb: - return '{ NULL, NULL }' - return '{ "%s", &%s }' % (cb['short_name'], cb['symbol']) + return ' { NULL, NULL }' + return ' { "%s", &%s }' % (cb['short_name'], cb['symbol']) class DeclarationTemplate(Template): def render(self): - out = "\n".join("extern %s;" % cb['declaration'] for cb in self.module.callbacks) + out = "\n".join("extern %s;" % cb['declaration'] for cb in self.module.callbacks) + "\n" if self.module.initialize: out += "extern %s;\n" % self.module.initialize['declaration'] @@ -36,12 +42,13 @@ class Module(object): class InfoTemplate(Template): def render(self): return Template( - r"""{ - "${clean_name}", - ${initialize}, - ${cleanup}, - ${cb_ptr}, ${cb_count}, ${enabled} - }""" + r""" + { + "${clean_name}", + ${initialize}, + ${cleanup}, + ${cb_ptr}, ${cb_count}, ${enabled} + }""" ).substitute( clean_name = self.module.clean_name(), initialize = self._render_callback(self.module.initialize), @@ -208,13 +215,13 @@ class TestSuite(object): data.write(t.render()) suites = "static struct clar_suite _clar_suites[] = {" + ','.join( - Module.InfoTemplate(module).render() for module in self.modules.values() - ) + "};" + Module.InfoTemplate(module).render() for module in sorted(self.modules.values(), key=lambda module: module.name) + ) + "\n};\n" data.write(suites) - data.write("static const size_t _clar_suite_count = %d;" % self.suite_count()) - data.write("static const size_t _clar_callback_count = %d;" % self.callback_count()) + data.write("static const size_t _clar_suite_count = %d;\n" % self.suite_count()) + data.write("static const size_t _clar_callback_count = %d;\n" % self.callback_count()) suite.save_cache() return True |
