From c9c345246c53f852c2c1915e1c8c0cdd9a33066a Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 26 Jul 2023 13:04:25 +0000 Subject: [PATCH] Bug 29324: (QA follow-up) Polishing Content-Type: text/plain; charset=utf-8 Making the verbose output a bit more manageable with -v option. If we just run the test, we get the total of files with license problems. --- xt/find-license-problems.t | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/xt/find-license-problems.t b/xt/find-license-problems.t index 0e1323c5ef..5d70902e75 100755 --- a/xt/find-license-problems.t +++ b/xt/find-license-problems.t @@ -24,16 +24,17 @@ # along with Koha; if not, see . use Modern::Perl; -use Test::More; +use Test::More tests => 1; use File::Spec; use File::Find; my @files; + sub wanted { my $name = $File::Find::name; push @files, $name - unless $name =~ /\/(\.git|koha-tmpl|node_modules|swagger-ui)(\/.*)?$/ || + unless $name =~ /\/(\.git|installer\/data\/mysql\/db_revs|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; @@ -41,6 +42,7 @@ sub wanted { find({ wanted => \&wanted, no_chdir => 1 }, File::Spec->curdir()); +my @fails; foreach my $name (@files) { open( my $fh, '<', $name ) || die "cannot open file $name $!"; my ( $hascopyright, $hasgpl, $hasv3, $hasorlater, $haslinktolicense, @@ -58,13 +60,19 @@ foreach my $name (@files) { $needs_copyright = 1 if $line =~ m|This file is part of Koha| || $name =~ /(.*).pl/ || $name =~ /(.*).pm/; } close $fh; - next unless $hascopyright || $needs_copyright; + next unless $needs_copyright &&!$hascopyright; next if $is_not_us; - is( $hascopyright - && $hasgpl - && $hasv3 - && $hasorlater - && $haslinktolicense - && !$hasfranklinst, 1 ) or diag(sprintf "File %s has wrong copyright: hascopyright=%s, hasgpl=%s, hasv3=%s, hasorlater=%s, haslinktolicense=%s, hasfranklinst=%s", $name, $hascopyright, $hasgpl, $hasv3, $hasorlater, $haslinktolicense, $hasfranklinst); + my $diagnostics = license_info( $hascopyright, $hasgpl, $hasv3, $hasorlater, $haslinktolicense, $hasfranklinst ); + push @fails, [ $name, $diagnostics ] if $diagnostics; +} +is( scalar @fails, 0, 'No files without license problems anymore!' ); + +if( grep { $_ eq '-v' } @ARGV ) { + map { print "File ". $_->[0]. ": ". $_->[1]. "\n"; } @fails; +} + +sub license_info { + my ( $hascopyright, $hasgpl, $hasv3, $hasorlater, $haslinktolicense, $hasfranklinst ) = @_; + return sprintf( "hascopyright=%s, hasgpl=%s, hasv3=%s, hasorlater=%s, haslinktolicense=%s, hasfranklinst=%s", $hascopyright, $hasgpl, $hasv3, $hasorlater, $haslinktolicense, $hasfranklinst ) unless $hascopyright && $hasgpl && $hasv3 && $hasorlater && $haslinktolicense && !$hasfranklinst; + return; } -done_testing; -- 2.30.2