summaryrefslogtreecommitdiff
path: root/unittest
diff options
context:
space:
mode:
Diffstat (limited to 'unittest')
-rw-r--r--unittest/mytap/tap.c6
-rw-r--r--unittest/mytap/tap.h43
-rw-r--r--unittest/unit.pl12
3 files changed, 59 insertions, 2 deletions
diff --git a/unittest/mytap/tap.c b/unittest/mytap/tap.c
index a99da3fd975..f9396adbd69 100644
--- a/unittest/mytap/tap.c
+++ b/unittest/mytap/tap.c
@@ -166,9 +166,15 @@ static signal_entry install_signal[]= {
#endif
};
+int skip_big_tests= 0;
+
void
plan(int const count)
{
+ char *config= getenv("MYTAP_CONFIG");
+
+ if (config)
+ skip_big_tests= strcmp(config, "big");
setvbuf(tapout, 0, _IONBF, 0); /* provide output at once */
/*
diff --git a/unittest/mytap/tap.h b/unittest/mytap/tap.h
index 31ec47d1ef2..f92fad1101f 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,7 +99,12 @@ 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);
@@ -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.
diff --git a/unittest/unit.pl b/unittest/unit.pl
index 9d328985012..b83132581f9 100644
--- a/unittest/unit.pl
+++ b/unittest/unit.pl
@@ -14,8 +14,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-use Test::Harness qw(&runtests $verbose);
+use Test::Harness;
use File::Find;
+use Getopt::Long;
use strict;
@@ -35,6 +36,15 @@ unit - Run unit tests in directory
=cut
+my $big=1;
+
+my $result = GetOptions (
+ "big!" => \$big,
+ "verbose!" => \$Test::Harness::verbose,
+);
+
+$ENV{'MYTAP_CONFIG'} = $big ? "big" : "";
+
my $cmd = shift;
if (defined $cmd && exists $dispatch{$cmd}) {