Debian Codegraph @

t/0gen.t

raw
1 use strict;
2 use warnings;
3
4 # check this first.
5 # win32 doesnt chdir during disttest, so the
6 # '.git' test will fire during disttest.
7 # (so dont build dists on win32!)
8 BEGIN {
9 if ( ! $ENV{UUID_DISTTEST} ) {
10 if ( -e '.git' ) { print "1..0 # SKIP in repo\n" }
11 else { print "1..0 # SKIP in release\n" }
12 exit 0;
13 }
14 }
15
16 use MyTest;
17 use CPAN::Meta ();
18 use ExtUtils::Manifest qw(maniread manicheck filecheck);
19 unshift @INC, 'blib/lib';
20 require 'UUID.pm';
21
22 plan tests => 21;
23
24 ok -e 'LICENSE', 'LICENSE exists';
25 ok -e 'META.json', 'META.json exists';
26 ok -e 'META.yml', 'META.yml exists';
27 ok -e 'README', 'README exists';
28
29 ok -s 'LICENSE', 'LICENSE not empty';
30 ok -s 'META.json', 'META.json not empty';
31 ok -s 'META.yml', 'META.yml not empty';
32 ok -s 'README', 'README not empty';
33
34 my $manifest = maniread;
35 ok exists($manifest->{'LICENSE'}), 'LICENSE in manifest';
36 ok exists($manifest->{'META.json'}), 'META.json in manifest';
37 ok exists($manifest->{'META.yml'}), 'META.yml in manifest';
38 ok exists($manifest->{'README'}), 'README in manifest';
39
40
41 ok test_dynamic('META.json'), 'META.json authoritative';
42 ok test_dynamic('META.yml'), 'META.yml authoritative';
43
44 sub test_dynamic {
45 my $f = shift;
46 open my $fh, '<', $f or die "open: $!";
47 while (<$fh>) {
48 return 1 if m/dynamic_config.*?0/;
49 }
50 return 0;
51 }
52
53
54 ok test_copyright('LICENSE'), 'LICENSE copyright date valid';
55 ok test_copyright('README'), 'README copyright date valid';
56 ok test_copyright('lib/UUID.pm'), 'UUID.pm copyright date valid';
57
58 sub test_copyright {
59 my $f = shift;
60 my $n = 1900 + (localtime(time))[5];
61 open my $fh, '<', $f or die 'open: ', $f, ': ', $!;
62 while (<$fh>) {
63 if (/2014-(\d+)/) {
64 my $end = $1;
65 return 1 if $end == $n;
66 }
67 }
68 return 0;
69 }
70
71
72 is provided_version('META.json'), $UUID::VERSION, 'META.json version';
73 is provided_version('META.yml'), $UUID::VERSION, 'META.yml version';
74
75 sub provided_version {
76 my $f = shift;
77 my $m = CPAN::Meta->load_file($f);
78 return $m->{'provides'}{'UUID'}{'version'};
79 }
80
81
82 ok manifest_complete(), 'all manifest files found';
83
84 sub manifest_complete {
85 $ExtUtils::Manifest::Quiet = 1;
86 my @missing = manicheck();
87 my $cnt = 0;
88 for my $f ( @missing ) {
89 warn "\n\n" unless $cnt++;
90 warn "# unfound: ", $f, "\n";
91 }
92 return @missing ? 0 : 1;
93 }
94
95
96 ok manifest_extras(), 'files not in manifest';
97
98 sub manifest_extras {
99 my @extras =
100 grep { ! m{MYMETA.json} }
101 grep { ! m{MYMETA.yml} }
102 grep { ! m{Makefile} }
103 grep { ! m{UUID.bs} }
104 grep { ! m{UUID.c} }
105 grep { ! m{UUID.o} }
106 grep { ! m{blib/arch/.exists} }
107 grep { ! m{blib/arch/auto/UUID/.exists} }
108 grep { ! m{blib/arch/auto/UUID/UUID.so} }
109 grep { ! m{blib/bin/.exists} }
110 grep { ! m{blib/lib/.exists} }
111 grep { ! m{blib/lib/auto/UUID/.exists} }
112 grep { ! m{blib/lib/UUID.pm} }
113 grep { ! m{blib/man1/.exists} }
114 grep { ! m{blib/man3/.exists} }
115 grep { ! m{blib/script/.exists} }
116 grep { ! m{ulib/EUMM.h} }
117 grep { ! m{ulib/atomic.o} }
118 grep { ! m{ulib/chacha.o} }
119 grep { ! m{ulib/clear.o} }
120 grep { ! m{ulib/clock.o} }
121 grep { ! m{ulib/compare.o} }
122 grep { ! m{ulib/copy.o} }
123 grep { ! m{ulib/futex.o} }
124 grep { ! m{ulib/gen.o} }
125 grep { ! m{ulib/gettime.o} }
126 grep { ! m{ulib/hash.o} }
127 grep { ! m{ulib/isnull.o} }
128 grep { ! m{ulib/md5.o} }
129 grep { ! m{ulib/node.o} }
130 grep { ! m{ulib/pack.o} }
131 grep { ! m{ulib/parse.o} }
132 grep { ! m{ulib/sha1.o} }
133 grep { ! m{ulib/splitmix.o} }
134 grep { ! m{ulib/sysrand.o} }
135 grep { ! m{ulib/unpack.o} }
136 grep { ! m{ulib/unparse.o} }
137 grep { ! m{ulib/util.o} }
138 grep { ! m{ulib/xoshiro.o} }
139 grep { ! m{uu_to_blib} }
140 filecheck()
141 ;
142 my $cnt = 0;
143 for my $f ( @extras ) {
144 warn "\n\n" unless $cnt++;
145 warn "# unlisted: ", $f, "\n";
146 }
147 return @extras ? 0 : 1;
148 }
149
150 done_testing;