From: Galen Charlton <[EMAIL PROTECTED]>

Added support for a new target in the test Makefile
to run a single test module.  If you do (for example)

make test-single TEST_FILES=lib/KohaTest/Biblio.pm

only the tests in that module will be run.  Unlike
the full test suite as run via 'make test', 'make test-single'
does not clear the test database before running the
tests.

Please note that "TEST_FILES=path/to/test/class.pm" is
required when using 'make test-single'.

Signed-off-by: Andrew Moore <[EMAIL PROTECTED]>
---
 t/Makefile        |    4 ++++
 t/lib/KohaTest.pm |   16 ++++++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/t/Makefile b/t/Makefile
index 213a513..b135359 100644
--- a/t/Makefile
+++ b/t/Makefile
@@ -62,6 +62,10 @@ test :: config_file $(ZEBRA_CONF_FILES) $(SCRIPTS)
        KOHA_CONF=$(TEST_CONF_FILE) PERL5LIB=$(PERL5LIB) 
TEST_CLASS=$(TEST_CLASS) RUN_EXPENSIVE_TESTS=$(RUN_EXPENSIVE_TESTS) \
                $(PROVE) $(PROVE_FLAGS) $(TEST_FILES) 
 
+test-single :: config_file $(ZEBRA_CONF_FILES) $(SCRIPTS)
+       KOHA_CONF=$(TEST_CONF_FILE) PERL5LIB=$(PERL5LIB) RUN_EXPENSIVE_TESTS=1 
SINGLE_TEST=1 \
+               $(PROVE) $(PROVE_FLAGS) -Ilib $(TEST_FILES)
+
 fulltest :: RUN_EXPENSIVE_TESTS = 1
 fulltest :: test
 
diff --git a/t/lib/KohaTest.pm b/t/lib/KohaTest.pm
index 8ff9fd0..31183ee 100644
--- a/t/lib/KohaTest.pm
+++ b/t/lib/KohaTest.pm
@@ -19,12 +19,28 @@ use C4::Search;
 use C4::Installer;
 use C4::Languages;
 use File::Temp qw/ tempdir /;
+use CGI;
 
 # Since this is an abstract base class, this prevents these tests from
 # being run directly unless we're testing a subclass. It just makes
 # things faster.
 __PACKAGE__->SKIP_CLASS( 1 );
 
+INIT {
+    if ($ENV{SINGLE_TEST}) {
+        # if we're running the tests in one
+        # or more test files specified via
+        #
+        #   make single-test TEST_FILES=lib/KohaTest/Foo.pm
+        #
+        # use this INIT trick taken from the POD for
+        # Test::Class::Load.
+        start_zebrasrv();
+        Test::Class->runtests;
+        stop_zebrasrv();
+    }
+}
+
 use Attribute::Handlers;
 
 =head2 Expensive test method attribute
-- 
1.5.6

_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha.org/mailman/listinfo/koha-patches

Reply via email to