From 07aad0475c25fe433d909c66931a93bd31285637 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 16 Jul 2025 14:56:43 -0300 Subject: [PATCH] Bug 40419: Changes to testing logic This patch makes a couple changes to the tests: * Remove check for Copyright line. The Copyright line should not be mandatory. * Remove dependency of GPL-related checks on the copyrigth line existence. (this highlights several missed checks). * Skip testing-related templates. Koha ships some templates that are not excluded correctly. This 'fix' will highlight existing errors that were skipped until now. To test: 1. Run: $ ktd --shell k$ prove xt/find-license-problems.t => FAIL: Tests pass! Some files should make them fail! 2. Apply this patch 3. Repeat 1 => SUCCESS: Tests fail! --- xt/find-license-problems.t | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xt/find-license-problems.t b/xt/find-license-problems.t index 92edba9353e..3c576b7a515 100755 --- a/xt/find-license-problems.t +++ b/xt/find-license-problems.t @@ -33,6 +33,7 @@ my @files = map { !( $name =~ m{^koha-tmpl/} || $name =~ m{\.(gif|jpg|odt|ogg|pdf|png|po|psd|svg|swf|zip)$} || $name =~ m{xt/find-license-problems|xt/fix-old-fsf-address|misc/translator/po2json} + || $name =~ m[t/mock_templates/intranet-tmpl/prog] || !-f $name ) ? $_ : () @@ -43,14 +44,13 @@ plan tests => scalar(@files) + 1; foreach my $name (@files) { open( my $fh, '<', $name ) || die "cannot open file $name $!"; my ( - $hascopyright, $hasgpl, $hasv3, $hasorlater, $haslinktolicense, + $hasgpl, $hasv3, $hasorlater, $haslinktolicense, $hasfranklinst, $is_not_us ) = (0) x 7; while ( my $line = <$fh> ) { - $hascopyright = 1 if ( $line =~ /^(#|--)?\s*Copyright.*\d\d/ ); - $hasgpl = 1 if ( $line =~ /GNU General Public License/ ); - $hasv3 = 1 if ( $line =~ /either version 3/ ); - $hasorlater = 1 + $hasgpl = 1 if ( $line =~ /GNU General Public License/ ); + $hasv3 = 1 if ( $line =~ /either version 3/ ); + $hasorlater = 1 if ( $line =~ /any later version/ || $line =~ /at your option/ ); $haslinktolicense = 1 if $line =~ m|http://www\.gnu\.org/licenses|; @@ -59,12 +59,12 @@ foreach my $name (@files) { } close $fh; - if ( !$hascopyright || $is_not_us ) { + if ( $is_not_us || !$hasgpl ) { pass(); next; } - is( $hasgpl && $hasv3 && $hasorlater && $haslinktolicense && !$hasfranklinst, 1 ) + ok( $hasgpl && $hasv3 && $hasorlater && $haslinktolicense && !$hasfranklinst ) or diag( sprintf "File %s has wrong copyright: hasgpl=%s, hasv3=%s, hasorlater=%s, haslinktolicense=%s, hasfranklinst=%s", -- 2.50.1