test suite - various changes
authorGalen Charlton <galen.charlton@liblime.com>
Fri, 18 Apr 2008 16:01:13 +0000 (11:01 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Mon, 21 Apr 2008 16:26:30 +0000 (11:26 -0500)
* All configuration and run-time files created during
  a test suite run now live under t/run
* made sure scripts copied to t/run/bin are executable
* added t/run and t/test-config.txt to .gitignore

Signed-off-by: Andrew Moore <andrew.moore@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>

.gitignore
Makefile.PL
t/Makefile
t/database_dependent.pl

index 740b7f5..034e580 100644 (file)
@@ -3,4 +3,6 @@
 *.old
 *.tgz
 *.iso2709
-.directory
\ No newline at end of file
+.directory
+t/run/
+t/test-config.txt
index ebb459c..175eec8 100644 (file)
@@ -507,6 +507,16 @@ if ($config{'INSTALL_MODE'} ne "dev") {
     );
 }
 
+my %test_suite_override_dirs = (
+    KOHA_CONF_DIR  => ['etc'],
+    ZEBRA_CONF_DIR => ['etc', 'zebradb'],
+    LOG_DIR        => ['var', 'log'],
+    SCRIPT_DIR     => ['bin'],
+    ZEBRA_LOCK_DIR => ['var', 'lock', 'zebradb'],
+    ZEBRA_DATA_DIR => ['var', 'lib', 'zebradb'],
+    ZEBRA_RUN_DIR  => ['var', 'run', 'zebradb'],
+);
 WriteMakefile(
     NAME => 'koha',
     #VERSION => strftime('2.9.%Y%m%d%H',gmtime),
@@ -1228,6 +1238,25 @@ sub get_target_directories {
     return \%dirmap, \%skipdirs;
 }
 
+=head2 get_test_dir 
+
+Map a directory target to the corresponding path for
+the test suite.
+
+=cut
+
+sub get_test_dir {
+    my ($dirname) = @_;
+  
+    my @basedir = (File::Spec->rel2abs(File::Spec->curdir()), 't', 'run'); 
+    if (exists $test_suite_override_dirs{$dirname}) {
+        return File::Spec->catdir(@basedir, @{ $test_suite_override_dirs{$dirname} });
+    } else {
+        return;
+    }
+    
+}
+
 sub _get_env_overrides {
     my $dirmap = shift;
 
@@ -1473,14 +1502,10 @@ sub postamble {
             print $confhandle "# It is separate from the standard koha-conf.xml so that you can edit this by hand and test with different configurations.\n";
 
             # these directories will be relocated to the 't' directory
-            my %move_to_t = map { $_ => 1 } qw( KOHA_CONF_DIR LOG_DIR SCRIPT_DIR ZEBRA_CONF_DIR ZEBRA_LOCK_DIR ZEBRA_DATA_DIR ZEBRA_RUN_DIR );
-            my $oldbasedir = substr( $target_directories->{'KOHA_CONF_DIR'}, 0, - length( '/etc' ) );
-            my $newbasedir = $target_directories->{'KOHA_CONF_DIR'};
-            $newbasedir =~ s/etc$/t/;
             foreach my $dirname ( keys %$target_directories ) {
-                my $dir = $target_directories->{ $dirname };
-                if ( $move_to_t{ $dirname } ) {
-                    $dir =~ s/$oldbasedir/$newbasedir/;
+                my $dir = $target_directories->{$dirname};
+                if ( exists $test_suite_override_dirs{$dirname} ) {
+                    $dir = main::get_test_dir($dirname);
                 }
                 print $confhandle "$dirname = $dir\n"
             }
index fa3c57f..a41907e 100644 (file)
@@ -6,6 +6,7 @@ ECHO = echo
 MKDIR = /bin/mkdir
 CP = cp
 SED = /bin/sed
+CHMOD = chmod
 
 # some of these are pretty questionable.
 PERL = /usr/bin/perl
@@ -15,18 +16,18 @@ PROVE = /usr/bin/prove
 PROVE_FLAGS = -v
 KOHA_CONF_DIR = ../etc
 CONF_FILE_TEMPLATE = $(KOHA_CONF_DIR)/koha-conf.xml 
-TEST_CONF_FILE = etc/koha-conf.xml
+TEST_CONF_FILE = run/etc/koha-conf.xml
 MKPATH = $(PERL) "-MExtUtils::Command" -e mkpath
 
 TEST_REWRITE_SCRIPT = rewrite-config-test.PL
 REAL_REWRITE_SCRIPT = ../rewrite-config.PL
 
-ZEBRA_CONF_DIR = etc/zebradb
+ZEBRA_CONF_DIR = run/etc/zebradb
 ZEBRA_CONF_FILES = $(ZEBRA_CONF_DIR)/etc/passwd $(ZEBRA_CONF_DIR)/zebra-biblios.cfg $(ZEBRA_CONF_DIR)/zebra-authorities.cfg $(ZEBRA_CONF_DIR)/zebra-authorities-dom.cfg $(ZEBRA_CONF_DIR)/explain-authorities.xml $(ZEBRA_CONF_DIR)/explain-biblios.xml $(ZEBRA_CONF_DIR)/retrieval-info-auth-grs1.xml $(ZEBRA_CONF_DIR)/retrieval-info-auth-dom.xml $(ZEBRA_CONF_DIR)/ccl.properties $(ZEBRA_CONF_DIR)/cql.properties $(ZEBRA_CONF_DIR)/pqf.properties
 
 SCRIPTS = koha-zebra-ctl.sh koha-pazpar2-ctl.sh koha-zebraqueue-ctl.sh zebraqueue_daemon.pl
 SRC_SCRIPT_DIR = ../misc/bin
-TEST_SCRIPT_DIR = bin
+TEST_SCRIPT_DIR = run/bin
 
 
 all ::
@@ -45,7 +46,6 @@ zebra_conf_files :: test_run_dirs $(ZEBRA_CONF_FILES)
 
 
 $(ZEBRA_CONF_FILES) ::
-       $(CP) ../$@ $@
        $(PERL) $(TEST_REWRITE_SCRIPT) --file $@
        $(PERL) $(REAL_REWRITE_SCRIPT)  $@
 
@@ -53,24 +53,26 @@ $(SCRIPTS) ::
        $(SED) s/--user=\$$USER.\$$GROUP// $(SRC_SCRIPT_DIR)/$@ > $(TEST_SCRIPT_DIR)/$@
        $(PERL) $(TEST_REWRITE_SCRIPT) --file $(TEST_SCRIPT_DIR)/$@
        $(PERL) $(REAL_REWRITE_SCRIPT)  $(TEST_SCRIPT_DIR)/$@
+       $(CHMOD) 755 $(TEST_SCRIPT_DIR)/$@
 
 test :: config_file $(ZEBRA_CONF_FILES) $(SCRIPTS)
        KOHA_CONF=$(TEST_CONF_FILE) $(PROVE) $(PROVE_FLAGS) $(TEST_FILES)
 
 test_run_dirs ::
-       $(CP) -a ../etc/zebradb etc
-       $(MKPATH) etc/zebradb/etc
-       $(MKPATH) var/lib/zebradb/biblios/key
-       $(MKPATH) var/lib/zebradb/biblios/register
-       $(MKPATH) var/lib/zebradb/biblios/shadow
-       $(MKPATH) var/lib/zebradb/biblios/tmp
-       $(MKPATH) var/lib/zebradb/authorities/key
-       $(MKPATH) var/lib/zebradb/authorities/register
-       $(MKPATH) var/lib/zebradb/authorities/shadow
-       $(MKPATH) var/lib/zebradb/authorities/tmp
-       $(MKPATH) var/lock/zebradb/biblios
-       $(MKPATH) var/lock/zebradb/authorities
-       $(MKPATH) var/run/zebradb
-       $(MKPATH) var/log/zebradb
-       $(MKPATH) bin
+       $(MKPATH) run/etc
+       $(CP) -a ../etc/zebradb run/etc
+       $(MKPATH) run/etc/zebradb/etc
+       $(MKPATH) run/var/lib/zebradb/biblios/key
+       $(MKPATH) run/var/lib/zebradb/biblios/register
+       $(MKPATH) run/var/lib/zebradb/biblios/shadow
+       $(MKPATH) run/var/lib/zebradb/biblios/tmp
+       $(MKPATH) run/var/lib/zebradb/authorities/key
+       $(MKPATH) run/var/lib/zebradb/authorities/register
+       $(MKPATH) run/var/lib/zebradb/authorities/shadow
+       $(MKPATH) run/var/lib/zebradb/authorities/tmp
+       $(MKPATH) run/var/lock/zebradb/biblios
+       $(MKPATH) run/var/lock/zebradb/authorities
+       $(MKPATH) run/var/run/zebradb
+       $(MKPATH) run/var/log/zebradb
+       $(MKPATH) run/bin
 
index 42348be..3afd422 100644 (file)
@@ -39,7 +39,7 @@ stop_zebrasrv();
 
 sub create_test_database {
 
-    diag 'creating testing datbase...';
+    diag 'creating testing database...';
     my $installer = C4::Installer->new() or die 'unable to create new installer';
     # warn Data::Dumper->Dump( [ $installer ], [ 'installer' ] );
     my $all_languages = getAllLanguages();
@@ -140,7 +140,7 @@ sub stop_zebrasrv {
 
 sub start_zebraqueue_daemon {
 
-    my $command = q(bin/koha-zebraqueue-ctl.sh start);
+    my $command = q(run/bin/koha-zebraqueue-ctl.sh start);
     diag $command;
     my $started = system( $command );
     diag "started: $started";
@@ -162,7 +162,7 @@ sub start_zebraqueue_daemon {
 
 sub stop_zebraqueue_daemon {
 
-    my $command = q(bin/koha-zebraqueue-ctl.sh stop);
+    my $command = q(run/bin/koha-zebraqueue-ctl.sh stop);
     diag $command;
     my $started = system( $command );
     diag "started: $started";