summaryrefslogtreecommitdiff
path: root/unittest/mytap/tap.h
diff options
context:
space:
mode:
Diffstat (limited to 'unittest/mytap/tap.h')
-rw-r--r--unittest/mytap/tap.h49
1 files changed, 45 insertions, 4 deletions
diff --git a/unittest/mytap/tap.h b/unittest/mytap/tap.h
index 31ec47d1ef2..d8f617c88fb 100644
--- a/unittest/mytap/tap.h
+++ b/unittest/mytap/tap.h
@@ -62,6 +62,24 @@ extern "C" {
#endif
/**
+ Defines whether "big" tests should be skipped.
+
+ This variable is set by plan() function unless MYTAP_CONFIG environment
+ variable is set to the string "big". It is supposed to be used as
+
+ @code
+ if (skip_big_tests) {
+ skip(1, "Big test skipped");
+ } else {
+ ok(life_universe_and_everything() == 42, "The answer is CORRECT");
+ }
+ @endcode
+
+ @see SKIP_BIG_TESTS
+*/
+extern int skip_big_tests;
+
+/**
@defgroup MyTAP_API MyTAP API
MySQL support for performing unit tests according to TAP.
@@ -81,10 +99,15 @@ extern "C" {
that generate a core, so if you want to override these signals, do
it <em>after</em> you have called the plan() function.
- @param count The planned number of tests to run.
+ It will also set skip_big_tests variable if MYTAP_CONFIG environment
+ variable is defined.
+
+ @see skip_big_tests
+
+ @param count The planned number of tests to run.
*/
-void plan(int count);
+void plan(int const count);
/**
@@ -103,7 +126,7 @@ void plan(int count);
which case nothing is printed.
*/
-void ok(int pass, char const *fmt, ...)
+void ok(int const pass, char const *fmt, ...)
__attribute__((format(printf,2,3)));
@@ -135,7 +158,7 @@ void ok(int pass, char const *fmt, ...)
@param reason A reason for skipping the tests
*/
-void skip(int how_many, char const *reason, ...)
+void skip(int how_many, char const *const reason, ...)
__attribute__((format(printf,2,3)));
@@ -161,6 +184,24 @@ void skip(int how_many, char const *reason, ...)
/**
+ Helper macro to skip a group of "big" tests. It is used in the following
+ manner:
+
+ @code
+ SKIP_BIG_TESTS(1)
+ {
+ ok(life_universe_and_everything() == 42, "The answer is CORRECT");
+ }
+ @endcode
+
+ @see skip_big_tests
+ */
+
+#define SKIP_BIG_TESTS(COUNT) \
+ if (skip_big_tests) skip((COUNT), "big test"); else
+
+
+/**
Print a diagnostics message.
@param fmt Diagnostics message in printf() format.