File: 0gen.t

package info (click to toggle)
libuuid-perl 0.37-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,092 kB
  • sloc: ansic: 2,374; perl: 580; makefile: 5
file content (132 lines) | stat: -rw-r--r-- 3,491 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
use strict;
use warnings;
use Test::More;
use MyNote;
use CPAN::Meta ();
use ExtUtils::Manifest qw(maniread manicheck filecheck);
use lib 'blib/lib';
require 'UUID.pm';

# check this first.
# win32 doesnt chdir during disttest, so the
# '.git' test will fire during disttest.
if ( $ENV{UUID_DISTTEST} ) {
    plan tests => 21;
}
elsif ( -e '.git' ) {
    plan skip_all => 'in repo';
}
else {
    plan skip_all => 'in release';
}

ok -e 'LICENSE',   'LICENSE exists';
ok -e 'META.json', 'META.json exists';
ok -e 'META.yml',  'META.yml exists';
ok -e 'README',    'README exists';

ok -s 'LICENSE',   'LICENSE not empty';
ok -s 'META.json', 'META.json not empty';
ok -s 'META.yml',  'META.yml not empty';
ok -s 'README',    'README not empty';

my $manifest = maniread;
ok exists($manifest->{'LICENSE'}),   'LICENSE in manifest';
ok exists($manifest->{'META.json'}), 'META.json in manifest';
ok exists($manifest->{'META.yml'}),  'META.yml in manifest';
ok exists($manifest->{'README'}),    'README in manifest';


ok test_dynamic('META.json'), 'META.json authoritative';
ok test_dynamic('META.yml'),  'META.yml authoritative';

sub test_dynamic {
    my $f = shift;
    open my $fh, '<', $f or die "open: $!";
    while (<$fh>) {
        return 1 if m/dynamic_config.*?0/;
    }
    return 0;
}


ok test_copyright('LICENSE'), 'LICENSE copyright date valid';
ok test_copyright('README'),  'README copyright date valid';
ok test_copyright('UUID.pm'), 'UUID.pm copyright date valid';

sub test_copyright {
    my $f = shift;
    my $n = 1900 + (localtime(time))[5];
    open my $fh, '<', $f or die 'open: ', $f, ': ', $!;
    while (<$fh>) {
        if (/2014-(\d+)/) {
            my $end = $1;
            return 1 if $end == $n;
        }
    }
    return 0;
}


is provided_version('META.json'), $UUID::VERSION, 'META.json version';
is provided_version('META.yml'),  $UUID::VERSION, 'META.yml version';

sub provided_version {
    my $f = shift;
    my $m = CPAN::Meta->load_file($f);
    return $m->{'provides'}{'UUID'}{'version'};
}


ok manifest_complete(), 'all manifest files found';

sub manifest_complete {
    $ExtUtils::Manifest::Quiet = 1;
    my @missing = manicheck();
    my $cnt = 0;
    for my $f ( @missing ) {
        warn "\n\n" unless $cnt++;
        warn "# unfound: ", $f, "\n";
    }
    return @missing ? 0 : 1;
}


ok manifest_extras(), 'files not in manifest';

sub manifest_extras {
    my @extras =
        grep { ! m{UUID.bs}         }
        grep { ! m{UUID.c}          }
        grep { ! m{UUID.o}          }
        grep { ! m{ulib/EUMM.h}     }
        grep { ! m{ulib/chacha.o}   }
        grep { ! m{ulib/clear.o}    }
        grep { ! m{ulib/clock.o}    }
        grep { ! m{ulib/compare.o}  }
        grep { ! m{ulib/copy.o}     }
        grep { ! m{ulib/gen.o}      }
        grep { ! m{ulib/gettime.o}  }
        grep { ! m{ulib/isnull.o}   }
        grep { ! m{ulib/md5.o}      }
        grep { ! m{ulib/node.o}     }
        grep { ! m{ulib/pack.o}     }
        grep { ! m{ulib/parse.o}    }
        grep { ! m{ulib/sha1.o}     }
        grep { ! m{ulib/splitmix.o} }
        grep { ! m{ulib/unpack.o}   }
        grep { ! m{ulib/unparse.o}  }
        grep { ! m{ulib/util.o}     }
        grep { ! m{ulib/xoshiro.o}  }
        grep { ! m{uu_to_blib}      }
        filecheck()
    ;
    my $cnt = 0;
    for my $f ( @extras ) {
        warn "\n\n" unless $cnt++;
        warn "# unlisted: ", $f, "\n";
    }
    return @extras ? 0 : 1;
}

exit 0;