File: 00_local_docininfo.t

package info (click to toggle)
libsnmp-info-perl 3.972002-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,300 kB
  • sloc: perl: 36,403; makefile: 2; sh: 1
file content (45 lines) | stat: -rw-r--r-- 1,024 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env perl
# 00_local_versionsync.t - Private test to check that all modules are listed in Info.pm

use warnings;
use strict;
use File::Find;
use Test::More;

eval "use File::Slurp";
plan skip_all => "File::Slurp required for testing version sync"
    if $@;

plan qw(no_plan);

my %Items;
# Grab all the =item's from Info.pm
open (I,"lib/SNMP/Info.pm") or fail("Can't open Info.pm");
while (<I>) {
    next unless /^\s*=item\s*(\S+)/;
    $Items{$1}++;
}
close I;

#warn "items : ",join(', ',keys %Items),"\n";

# Check that each package is represented in Info.pm docs
find({wanted => \&check_version, no_chdir => 1}, 'lib');

sub check_version {
    # $_ is the full path to the file
    return unless (m{lib/}xms and m{\.pm \z}xms);

    my $content = read_file($_);

    # Make sure that this package is listed in Info.pm
    fail($_) unless $content =~ m/^\s*package\s+(\S+)\s*;/m;

    my $package = $1;

    return if $package eq 'SNMP::Info';

    fail($_) unless defined $Items{$package};

    pass($_);
}