Bug 39304: Make sure git commands return something

Jenkins is not failing when git command fails.

We edited the config and it broke the git repo:

13:32:35 koha_1       | error: unable to normalize alternate object path: /srv/jenkins/workspace/Koha_Source/.git/objects
13:32:35 koha_1       | fatal: not a tree object
13:32:35 koha_1       | [12:29:31] xt/check_makefile.t

So tests were not running correctly

Maybe it will be a problem for people running the tests without being
inside a git repo, but for now we need to ensure the community CI does
what we think it does.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 0075ca7356)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Jonathan Druart 2025-03-11 15:01:11 +01:00 committed by Fridolin Somers
parent ac8168a754
commit 9d60bf411f
6 changed files with 20 additions and 14 deletions

View File

@ -16,10 +16,11 @@
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Test::More tests => 1;
use Test::More tests => 2;
use File::Slurp;
my @files = `git ls-tree HEAD|tr -s '\t' ' '|cut -d' ' -f4`;
ok( @files > 0, 'We should test something' );
my $MakeFile = read_file('Makefile.PL');
my @MakeFile = split "\n", $MakeFile;

View File

@ -19,19 +19,20 @@
use Modern::Perl;
use Test::More;
plan tests => 1;
plan tests => 2;
use File::Spec;
use File::Slurp qw( read_file );
use Data::Dumper;
my $curdir = File::Spec->curdir();
my @dirs = `git ls-tree -d --name-only HEAD`;
my @dirs = `git ls-tree -d --name-only HEAD`;
ok( @dirs > 0, 'We should test something' );
my $makefile = read_file("$curdir/Makefile.PL");
my @missing;
for my $d ( sort @dirs ) {
chomp $d;
next if $d =~ /^debian$/;
next if $d =~ /^debian$/;
next if $makefile =~ m{'\./$d('|\/)}xms;
push @missing, $d;
}

View File

@ -18,7 +18,7 @@
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Test::More tests => 1;
use Test::More tests => 2;
use File::Slurp;
use Data::Dumper;
@ -31,6 +31,7 @@ push @files, `git ls-files 'koha-tmpl/opac-tmpl/bootstrap/en/*.inc'`;
# Staff
push @files, `git ls-files 'koha-tmpl/intranet-tmpl/prog/en/*.tt'`;
push @files, `git ls-files 'koha-tmpl/intranet-tmpl/prog/en/*.inc'`;
ok( @files > 0, 'We should test something' );
my @errors;

View File

@ -16,7 +16,7 @@
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Test::More tests => 1;
use Test::More tests => 2;
use File::Slurp qw( read_file );
use Data::Dumper;
use t::lib::QA::TemplateFilters;
@ -30,14 +30,15 @@ push @files, `git ls-files 'koha-tmpl/opac-tmpl/bootstrap/en/*.inc'`;
# Staff
push @files, `git ls-files 'koha-tmpl/intranet-tmpl/prog/en/*.tt'`;
push @files, `git ls-files 'koha-tmpl/intranet-tmpl/prog/en/*.inc'`;
ok( @files > 0, 'We should test something' );
my @errors;
for my $file ( @files ) {
for my $file (@files) {
chomp $file;
my $content = read_file($file);
my @e = t::lib::QA::TemplateFilters::missing_filters($content);
my @e = t::lib::QA::TemplateFilters::missing_filters($content);
push @errors, { file => $file, errors => \@e } if @e;
}
is( @errors, 0, "Template variables should be correctly escaped" )
or diag(Dumper @errors);
or diag( Dumper @errors );

View File

@ -18,7 +18,7 @@
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Test::More tests => 1;
use Test::More tests => 2;
use File::Slurp;
use Data::Dumper;
@ -31,12 +31,13 @@ push @files, `git ls-files 'koha-tmpl/opac-tmpl/bootstrap/en/*.inc'`;
# Staff
push @files, `git ls-files 'koha-tmpl/intranet-tmpl/prog/en/*.tt'`;
push @files, `git ls-files 'koha-tmpl/intranet-tmpl/prog/en/*.inc'`;
ok( @files > 0, 'We should test something' );
my @errors;
for my $file ( @files ) {
for my $file (@files) {
chomp $file;
my @e = catch_missing_op($file);
push @errors, sprintf "%s:%s", $file, join (",", @e) if @e;
push @errors, sprintf "%s:%s", $file, join( ",", @e ) if @e;
}
is(
@ -72,7 +73,7 @@ sub catch_missing_op {
} else {
push @errors, $line_open_form;
}
$has_op = 0;
$has_op = 0;
$in_form = 0;
}
}

View File

@ -18,7 +18,7 @@
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Test::More tests => 1;
use Test::More tests => 2;
use File::Slurp qw( read_file );
my @files;
@ -30,6 +30,7 @@ push @files, `git ls-files 'koha-tmpl/opac-tmpl/bootstrap/en/*.inc'`;
# Staff
push @files, `git ls-files 'koha-tmpl/intranet-tmpl/prog/en/*.tt'`;
push @files, `git ls-files 'koha-tmpl/intranet-tmpl/prog/en/*.inc'`;
ok( @files > 0, 'We should test something' );
my @errors;
for my $file ( @files ) {