File: fedora.t

package info (click to toggle)
libstring-license-perl 0.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,892 kB
  • sloc: perl: 1,519; cpp: 360; ansic: 210; python: 27; ruby: 21; xml: 16; sh: 8; makefile: 3
file content (105 lines) | stat: -rw-r--r-- 3,240 bytes parent folder | download
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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;

# undetected or misdetected
# TODO: add/update patterns in Regexp::Pattern::License
my %broken = (
	'MIT-Cheusov'                     => 'UNKNOWN',
	'MIT-Minimal'                     => 'UNKNOWN',
	'MIT-Bellcore'                    => 'UNKNOWN',
	'MIT-Old-Style-disclaimer-no-doc' => 'UNKNOWN',
	'Unicode'                         => 'UNKNOWN',    # unicode_dfs_2005
	'MIT-UnixCrypt-Variant'           => 'UNKNOWN',
);

plan 33 + keys %broken;

# weakly labeled
# TODO: add Fedora names in Regexp::Pattern::License
my %imperfect = (
	'Adobe-Glyph'           => 'MIT-Adobe-Glyph-List',
	Boost                   => 'MIT-Thrift',
	bdwgc                   => 'MIT-Another-Minimal',
	'DSDP'                  => 'MIT-PetSC',
	'Festival'              => 'MIT-Festival',
	ICU                     => 'MIT-ICU',
	libtiff                 => 'MIT-Hylafax',
	mit_epinions            => 'MIT-Epinions',
	mit_mpich2              => 'MIT-mpich2',
	mit_new                 => 'MIT-sublicense',
	mit_old                 => 'MIT-Modern',
	mit_oldstyle_disclaimer => 'MIT-Old-Style-disclaimer',
	mit_oldstyle            => 'MIT-Old-Style',
	mit_openvision          => 'MIT-OpenVision',
	mit_osf                 => 'MIT-HP',
	mit_unixcrypt           => 'MIT-UnixCrypt',
	mit_whatever            => 'MIT-Whatever',
	mit_widget              => 'MIT-Nuclear',
	mit_xfig                => 'MIT-Xfig',
	mpich2                  => 'MIT-mpich2',
	ntp_disclaimer          => 'MIT-Old-Style-disclaimer-no-ad',
	NTP                     => 'MIT-Old-Style-no-ad',
	SMLNJ                   => 'MIT-Mlton',
	WordNet                 => 'MIT-WordNet',
);

# source text needs cleanup of comment markers and other cruft
my %crufty = (
	'MIT-Old-Style-disclaimer-no-ad' => undef,
	'PostgreSQL'                     => undef,
	'MIT-feh'                        => undef,
	'MIT-Nuclear'                    => undef,
	'MIT-Old-Style-no-ad'            => undef,
	'MIT-sublicense'                 => undef,
	'MIT-CMU'                        => undef,
	'MIT-Mlton'                      => undef,
	'MIT-ICU'                        => undef,
	'MIT-Modern'                     => undef,
	'MIT-Whatever'                   => undef,
	'MIT-Adobe-Glyph-List'           => undef,
	'MIT-mpich2'                     => undef,
	'MIT-enna'                       => undef,
	'MIT-Another-Minimal'            => undef,
);

my $naming = String::License::Naming::Custom->new(
	schemes => [qw(fedora internal)] );

sub scanner
{
	my $expected = $_->basename('.txt');

	return if $expected eq $_->basename;

	my $string = $_->slurp_utf8;
	$string = uncruft($string)
		if exists $crufty{$expected};

	my $license = String::License->new(
		string => $string,
		naming => $naming,
	)->as_text;
	my $todo;

	if ( exists $broken{$expected} ) {
		like $imperfect{$license} || $license,
			qr/^\Q$expected\E|\Q$broken{$expected}\E$/,
			"Corpus file $_";
		$todo = todo 'not yet implemented';
	}
	is( $imperfect{$license} || $license, $expected,
		"Corpus file $_"
	);
}

path("t/fedora")->visit( \&scanner );

done_testing;