diff --git a/xt/find-license-problems.t b/xt/find-license-problems.t index 50e607edea..9d01cf4544 100755 --- a/xt/find-license-problems.t +++ b/xt/find-license-problems.t @@ -25,21 +25,20 @@ use Modern::Perl; use Test::More; +use Test::NoWarnings; -use File::Spec; -use File::Find; +my @files = map { + chomp; + my $name = $_; + !( $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} + || !-f $name ) + ? $_ + : () +} `git ls-tree -r HEAD --name-only`; # only files part of git -my @files; -sub wanted { - my $name = $File::Find::name; - push @files, $name - unless $name =~ /\/(\.git|koha-tmpl|node_modules|swagger-ui)(\/.*)?$/ || - $name =~ /\.(gif|jpg|odt|ogg|pdf|png|po|psd|svg|swf|zip|patch)$/ || - $name =~ m[(xt/find-license-problems|xt/fix-old-fsf-address|misc/translator/po2json)] || - ! -f $name; -} - -find({ wanted => \&wanted, no_chdir => 1 }, File::Spec->curdir()); +plan tests => scalar(@files) + 1; foreach my $name (@files) { open( my $fh, '<', $name ) || die "cannot open file $name $!"; @@ -57,12 +56,16 @@ foreach my $name (@files) { $is_not_us = 1 if $line =~ m|This file is part of the Zebra server|; } close $fh; - next unless $hascopyright; - next if $is_not_us; - is( $hasgpl - && $hasv3 - && $hasorlater - && $haslinktolicense - && !$hasfranklinst, 1 ) or diag(sprintf "File %s has wrong copyright: hasgpl=%s, hasv3=%s, hasorlater=%s, haslinktolicense=%s, hasfranklinst=%s", $name, $hasgpl, $hasv3, $hasorlater, $haslinktolicense, $hasfranklinst); + + if ( !$hascopyright || $is_not_us ) { + pass(); + next; + } + + is( $hasgpl && $hasv3 && $hasorlater && $haslinktolicense && !$hasfranklinst, 1 ) + or diag( + sprintf + "File %s has wrong copyright: hasgpl=%s, hasv3=%s, hasorlater=%s, haslinktolicense=%s, hasfranklinst=%s", + $name, $hasgpl, $hasv3, $hasorlater, $haslinktolicense, $hasfranklinst + ); } -done_testing;