Commit e8a92fe1 by Russell Belfer

Update clar to a80e7f30

parent 1bf7bee3
/*
* 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;
}
if (exact)
break;
}
}
if (j == _clar_suite_count) {
if (!found) {
clar_print_onabort("No suite matching '%s' found.\n", argument);
exit(-1);
}
......
/*
* 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__
......
......@@ -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, ...)
......
#!/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,7 +42,8 @@ class Module(object):
class InfoTemplate(Template):
def render(self):
return Template(
r"""{
r"""
{
"${clean_name}",
${initialize},
${cleanup},
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment