From e9f0dfb572c893823efbb9d2ff726f19f7df18a7 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Wed, 25 Mar 2015 19:58:51 +0100 Subject: [PATCH] Added fnmatch conditional for Windows portability --- configure.ac | 2 ++ src/main.c | 6 ++++++ src/report.c | 8 +++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index bddf447..e8de7d2 100644 --- a/configure.ac +++ b/configure.ac @@ -20,6 +20,8 @@ AC_PROG_LN_S AC_PROG_MAKE_SET AC_SUBST([LIBTOOL_DEPS]) +AC_FUNC_FNMATCH + AC_ARG_ENABLE([gcov], [AS_HELP_STRING([--enable-gcov], [Compile the project with converage enabled])], diff --git a/src/main.c b/src/main.c index 467e49d..4ee1c76 100644 --- a/src/main.c +++ b/src/main.c @@ -112,7 +112,9 @@ int main(int argc, char *argv[]) { {"list", no_argument, 0, 'l'}, {"ascii", no_argument, 0, 'k'}, {"fail-fast", no_argument, 0, 'f'}, +#ifdef HAVE_FNMATCH {"pattern", required_argument, 0, 'p'}, +#endif {"always-succeed", no_argument, 0, 'y'}, {"no-early-exit", no_argument, 0, 'z'}, {0, 0, 0, 0 } @@ -124,7 +126,9 @@ int main(int argc, char *argv[]) { .fail_fast = !strcmp("1", getenv("CRITERION_FAIL_FAST") ?: "0"), .use_ascii = !strcmp("1", getenv("CRITERION_USE_ASCII") ?: "0"), .logging_threshold = atoi(getenv("CRITERION_VERBOSITY_LEVEL") ?: "2"), +#ifdef HAVE_FNMATCH .pattern = getenv("CRITERION_TEST_PATTERN"), +#endif .output_provider = NORMAL_LOGGING, }; @@ -140,7 +144,9 @@ int main(int argc, char *argv[]) { case 'z': criterion_options.no_early_exit = true; break; case 'k': criterion_options.use_ascii = true; break; case 'f': criterion_options.fail_fast = true; break; +#ifdef HAVE_FNMATCH case 'p': criterion_options.pattern = optarg; break; +#endif case 't': use_tap = true; break; case 'l': do_list_tests = true; break; case 'v': do_print_version = true; break; diff --git a/src/report.c b/src/report.c index 5c70807..542f813 100644 --- a/src/report.c +++ b/src/report.c @@ -24,13 +24,17 @@ #define _GNU_SOURCE #include #include -#include #include "criterion/types.h" #include "criterion/stats.h" #include "criterion/logging.h" #include "criterion/options.h" #include "criterion/ordered-set.h" #include "report.h" +#include "config.h" + +#ifdef HAVE_FNMATCH +#include +#endif #define IMPL_CALL_REPORT_HOOKS(Kind) \ IMPL_SECTION_LIMITS(f_report_hook, crit_ ## Kind); \ @@ -53,6 +57,7 @@ __attribute__((always_inline)) static inline void nothing() {} IMPL_REPORT_HOOK(PRE_ALL)(struct criterion_test_set *set) { +#ifdef HAVE_FNMATCH if (criterion_options.pattern) { FOREACH_SET(struct criterion_suite_set *s, set->suites) { if ((s->suite.data && s->suite.data->disabled) || !s->tests) @@ -64,6 +69,7 @@ IMPL_REPORT_HOOK(PRE_ALL)(struct criterion_test_set *set) { } } } +#endif log(pre_all, set); }