Tomas Cohen Arazi
357bb7e1e3
This patch makes the t/db_dependent/Search.t tests use a real DB instead of mocking the DB handler (which is not actually used and generates unnecesary warnings when running the tests). It does so by grabbing the DB configuration data using C4::Context->config() and passing it (writing %ENV) to rewrite-config.PL, all is done in zebra_config.pl which is only used on the Search.t file. To test: - Run $ prove t/db_dependent/Search.t => FAIL: Warnings are raised about DB being mocked and DBIC not recognising 'Mock' as a valid DB driver. - Apply the patch - Run $ prove r/db_dependent/Search.t => SUCCESS: Same tests results, no warning about DBIC driver. - Sign off :-D Disclamer: As of writing this patch, the Search.t tests pass. The patch is not dealing with tests results, but how they use the DB. Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> Test pass before & after, a 'little' less noisy No errors Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
84 lines
3 KiB
Perl
Executable file
84 lines
3 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;
|
|
|
|
use C4::Context;
|
|
|
|
my $source = File::Spec->rel2abs('.');
|
|
my $destination = $ARGV[0];
|
|
my $marc_type = $ARGV[1] || 'marc21';
|
|
my $indexing_mode = $ARGV[2] || 'dom';
|
|
|
|
$ENV{__BIB_INDEX_MODE__} = $indexing_mode;
|
|
$ENV{__AUTH_INDEX_MODE__} = $indexing_mode;
|
|
|
|
$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/lock/zebradb/rebuild");
|
|
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;
|
|
|
|
$ENV{'__DB_TYPE__'} = C4::Context->config('db_scheme') // 'mysql';
|
|
$ENV{'__DB_NAME__'} = C4::Context->config('database') // 'koha';
|
|
$ENV{'__DB_HOST__'} = C4::Context->config('hostname') // 'localhost';
|
|
$ENV{'__DB_PORT__'} = C4::Context->config('port') // '3306';
|
|
$ENV{'__DB_USER__'} = C4::Context->config('user') // 'kohaadmin';
|
|
$ENV{'__DB_PASS__'} = C4::Context->config('pass') // 'katikoan';
|
|
|
|
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");
|
|
}
|