Bug 40402: Make xt/find-license-problems.t process files that are in the git index
And only those files. Currently the test is failing with 02:52:31 koha_1 | # Failed test at xt/find-license-problems.t line 65. 02:52:31 koha_1 | # got: '0' 02:52:31 koha_1 | # expected: '1' 02:52:33 koha_1 | # File ./misc/translator/po/LICENSE has wrong copyright: hasgpl=1, hasv3=1, hasorlater=1, haslinktolicense=0, hasfranklinst=0 02:52:33 koha_1 | # Looks like you failed 1 test of 1381. 02:52:33 koha_1 | [00:51:24] xt/find-license-problems.t Because a LICENSE file has been added to koha-l10n, and now this test fails on it.27ab9ff4d2But we should not test files that are not part of the git index. Test plan: 0. Do not apply this patch 1. Edit xt/find-license-problems.t, add warn scalar(@files); 2. Run `prove xt/find-license-problems.t` => Notice that 4056 files are processed Note that you need to have a clean git repo. You can run the following git command BUT BEWARE /*\ it will remove all changes not committed `git clean -d -f` 3. Apply this patch, prove again => Tests are passing, with the same number of tests xt/find-license-problems.t .. ok All tests successful. Files=1, Tests=4056 Note that I think we lost one file, as Test::NoWarnings is adding a test. But I don't think it is worth the trouble to find out which one is missing. Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> (cherry picked from commit491ffdc7f1) Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
parent
a067120e70
commit
779c9cb17d
|
|
@ -25,22 +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 $!";
|
||||
|
|
@ -60,8 +58,12 @@ 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;
|
||||
|
||||
if ( !$hascopyright || $is_not_us ) {
|
||||
pass();
|
||||
next;
|
||||
}
|
||||
|
||||
is( $hasgpl && $hasv3 && $hasorlater && $haslinktolicense && !$hasfranklinst, 1 )
|
||||
or diag(
|
||||
sprintf
|
||||
|
|
@ -69,4 +71,3 @@ foreach my $name (@files) {
|
|||
$name, $hasgpl, $hasv3, $hasorlater, $haslinktolicense, $hasfranklinst
|
||||
);
|
||||
}
|
||||
done_testing;
|
||||
|
|
|
|||
Loading…
Reference in New Issue