Koha/t/db_dependent/zebra_config.pl
Galen Charlton 5ca295738a Bug 11137: regression tests for QP search field alias bug
This patch adds regression tests to verify that
Boolean searches using QueryParser function correctly.

This patch also ensures that QP is correctly initalized
when Search.t is run.

To test:

[1] Apply this patch and the following patch.
[2] Verify that prove -v t/QueryParser.t works
[3] Verify that prove -v t/db_dependent/Search.t works
[4] (optional) instead of applying both patches at the same
    time, apply only the regression test patch and run the
    tests listed in steps 2 and 3.  The following tests
    should fail:

t/db_dependent/Search.t (Wstat: 512 Tests: 198 Failed: 2)
  Failed tests:  42, 71
  Non-zero exit status: 2
t/QueryParser.t (Wstat: 256 Tests: 28 Failed: 1)
  Failed test:  12
  Non-zero exit status: 1

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
2013-11-14 15:50:16 +00:00

70 lines
2.4 KiB
Perl
Executable file

#!/usr/bin/perl
use Modern::Perl;
use File::Copy;
use File::Path qw(make_path);
use File::Find;
use File::Basename;
use File::Spec;
my $source = File::Spec->rel2abs('.');
my $destination = $ARGV[0];
my $marc_type = $ARGV[1] || 'marc21';
my $indexing_mode = $ARGV[2] || 'grs1';
$ENV{__ZEBRA_MARC_FORMAT__} = $marc_type;
if ($indexing_mode eq 'dom') {
$ENV{__ZEBRA_BIB_CFG__} = 'zebra-biblios-dom.cfg';
$ENV{__BIB_RETRIEVAL_CFG__} = 'retrieval-info-bib-dom.xml';
$ENV{__ZEBRA_AUTH_CFG__} = 'zebra-authorities-dom.cfg';
$ENV{__AUTH_RETRIEVAL_CFG__} = 'retrieval-info-auth-dom.xml';
} else {
$ENV{__ZEBRA_BIB_CFG__} = 'zebra-biblios.cfg';
$ENV{__BIB_RETRIEVAL_CFG__} = 'retrieval-info-bib-grs1.xml';
$ENV{__ZEBRA_AUTH_CFG__} = 'zebra-authorities.cfg';
$ENV{__AUTH_RETRIEVAL_CFG__} = 'retrieval-info-auth-grs1.xml';
}
make_path("$destination/var/lock/zebradb");
make_path("$destination/var/lock/zebradb/biblios");
make_path("$destination/var/lock/zebradb/authorities");
make_path("$destination/var/lib/zebradb");
make_path("$destination/var/lib/zebradb/biblios");
make_path("$destination/var/lib/zebradb/biblios/key");
make_path("$destination/var/lib/zebradb/biblios/register");
make_path("$destination/var/lib/zebradb/biblios/shadow");
make_path("$destination/var/lib/zebradb/biblios/tmp");
make_path("$destination/var/lib/zebradb/authorities");
make_path("$destination/var/lib/zebradb/authorities/key");
make_path("$destination/var/lib/zebradb/authorities/register");
make_path("$destination/var/lib/zebradb/authorities/shadow");
make_path("$destination/var/lib/zebradb/authorities/tmp");
make_path("$destination/var/run/zebradb");
$ENV{'INSTALL_BASE'} = $destination;
$ENV{'__INSTALL_BASE__'} = $destination;
my @files = ( "$source/etc/koha-conf.xml",
"$source/etc/searchengine/queryparser.yaml",
);
find(sub { push @files, $File::Find::name if ( -f $File::Find::name ); }, "$source/etc/zebradb");
foreach my $file (@files) {
my $target = "$file";
$target =~ s#$source#$destination#;
$target =~ s#etc/zebradb#etc/koha/zebradb#;
unlink($target);
make_path(dirname($target));
copy("$file", "$target");
system("perl $source/rewrite-config.PL $target");
if ($file =~ m/xml/) {
replace("$target", "$destination/intranet/templates", "$source/koha-tmpl/intranet-tmpl");
}
}
sub replace {
my ($file, $pattern, $replacement) = @_;
system("sed -i -e 's#$pattern#$replacement#' $file");
}