1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
use Test2::V0;
use Test2::Require::Module 'Regexp::Pattern::License' => '3.9.0';
use Path::Tiny;
use lib 't/lib';
use Uncruft;
use String::License;
use String::License::Naming::Custom;
my $CORPUS_DIR = 't/OSI';
my %crufty = (
'BSD-2-Clause-Views' => undef,
'BSD-3-Clause' => undef,
'GPL-2.0' => undef,
ISC => undef,
MIT => undef,
'MPL-1.1' => undef,
'MPL-2.0' => undef,
NTP => undef,
'Python-2.0' => 'CNRI-Python and/or PSF-2.0',
Zlib => undef,
);
plan 26 + grep {defined} values %crufty;
my $naming
= String::License::Naming::Custom->new( schemes => [qw(osi internal)] );
sub scanner
{
my ($path) = @_;
my $expected = $path->basename('.txt');
my $string = $path->slurp_utf8;
my $got = String::License->new(
string => $string,
naming => $naming,
)->as_text;
my $todo;
if ( exists $crufty{ $path->relative($CORPUS_DIR) } ) {
my $tolerated = $crufty{ $path->relative($CORPUS_DIR) };
if ( defined $tolerated ) {
my $got_too = String::License->new(
string => uncruft($string),
naming => $naming,
)->as_text;
note qq{tolerated: "$tolerated"};
like $got_too, qr/^\Q$expected\E|\Q$tolerated\E$/,
"Corpus file $path, pristine";
}
$todo = todo 'source content is messy';
}
like $got, $expected, "Corpus file $path";
}
path($CORPUS_DIR)->visit( \&scanner );
done_testing;
|