diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-10-05 16:34:19 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-12-22 11:56:35 +0100 |
| commit | 4efd8084ecf47132ba51577ee3f79d2ed2637b44 (patch) | |
| tree | 09f6c30c079be1de57af19c450dd6cb5fa4ff036 /core/tap.h | |
| parent | cca3d303023d53b5d0af96751f379b2d0e28cd18 (diff) | |
| download | vis-4efd8084ecf47132ba51577ee3f79d2ed2637b44.tar.gz vis-4efd8084ecf47132ba51577ee3f79d2ed2637b44.tar.xz | |
test/core: tweak tests to work with tis-interpreter
$ tis-inertpreter.sh --cc "-I. -I../.." text.c ../../text.c
or more conveniently
$ make tis
Diffstat (limited to 'core/tap.h')
| -rw-r--r-- | core/tap.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/core/tap.h b/core/tap.h new file mode 100644 index 0000000..98f5a35 --- /dev/null +++ b/core/tap.h @@ -0,0 +1,42 @@ +#ifndef TAP_H +#define TAP_H + +#ifdef TIS_INTERPRETER +static int failures = 0; +static int test_count = 0; +static void plan_no_plan(void) { } + +static int exit_status() { + if (failures > 255) + failures = 255; + return failures; +} + +#define ok(e, ...) do { \ + bool _e = (e); \ + printf("%sok %d - ", _e ? "" : "not ", ++test_count); \ + printf(__VA_ARGS__); \ + if (!_e) { \ + failures++; \ + printf(" Failed test (%s:%s() at line %d)\n", __FILE__, __func__, __LINE__); \ + } \ +} while (0) + +#define skip_if(cond, n, ...) \ + if (cond) skip((n), __VA_ARGS__); \ + else + +#define skip(n, ...) do { \ + int _n = (n); \ + while (_n--) { \ + printf("ok %d # skip ", ++test_count); \ + printf(__VA_ARGS__); \ + } \ +} while (0) + +#else +#include <ccan/tap/tap.h> +#define TIS_INTERPRETER 0 +#endif + +#endif |
