From 9d60bf411ffef3ed2472cbf331dffc321f1596f4 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 11 Mar 2025 15:01:11 +0100 Subject: [PATCH] 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 Signed-off-by: Katrin Fischer (cherry picked from commit 0075ca73563822d011c65d7a77a851004965426e) Signed-off-by: Fridolin Somers --- t/Makefile.t | 3 ++- xt/check_makefile.t | 7 ++++--- xt/find-missing-csrf.t | 3 ++- xt/find-missing-filters.t | 9 +++++---- xt/find-missing-op-in-forms.t | 9 +++++---- xt/single_quotes.t | 3 ++- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/t/Makefile.t b/t/Makefile.t index a0cdeab5cc..260333d2f2 100755 --- a/t/Makefile.t +++ b/t/Makefile.t @@ -16,10 +16,11 @@ # along with Koha; if not, see . 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; diff --git a/xt/check_makefile.t b/xt/check_makefile.t index 91235bfa14..bbdb4ccb3e 100755 --- a/xt/check_makefile.t +++ b/xt/check_makefile.t @@ -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; } diff --git a/xt/find-missing-csrf.t b/xt/find-missing-csrf.t index 95cbe07a5e..d3838b190b 100755 --- a/xt/find-missing-csrf.t +++ b/xt/find-missing-csrf.t @@ -18,7 +18,7 @@ # along with Koha; if not, see . 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; diff --git a/xt/find-missing-filters.t b/xt/find-missing-filters.t index 2cd461a56a..0aefa3707c 100755 --- a/xt/find-missing-filters.t +++ b/xt/find-missing-filters.t @@ -16,7 +16,7 @@ # along with Koha; if not, see . 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 ); diff --git a/xt/find-missing-op-in-forms.t b/xt/find-missing-op-in-forms.t index 483601f8e3..840d8b994b 100755 --- a/xt/find-missing-op-in-forms.t +++ b/xt/find-missing-op-in-forms.t @@ -18,7 +18,7 @@ # along with Koha; if not, see . 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; } } diff --git a/xt/single_quotes.t b/xt/single_quotes.t index 2c88d78c33..d2e947d358 100755 --- a/xt/single_quotes.t +++ b/xt/single_quotes.t @@ -18,7 +18,7 @@ # along with Koha; if not, see . 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 ) {