blob: 36d99615592e4504dd2c563dc9d0ab5a8c6f0edb (
plain)
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
|
#!/usr/bin/perl
use strict;
use warnings;
use Syntax::Keyword::Try;
use Test::More;
use Lintian::Deb822;
my %TESTS_BAD = (
'pgp-sig-before-start' => qr/PGP signature before message/,
'pgp-two-signatures' => qr/Found two PGP signatures/,
'pgp-unexpected-header' => qr/Unexpected .+ header/,
'pgp-malformed-header' => qr/Malformed PGP header/,
'pgp-two-signed-msgs' => qr/Multiple PGP messages/,
'pgp-no-end-pgp-header' => qr/Cannot find END PGP SIGNATURE/,
'pgp-leading-unsigned' => qr/Expected PGP MESSAGE header/,
'pgp-trailing-unsigned' => qr/Data after PGP SIGNATURE/,
'pgp-eof-missing-sign' => qr/Cannot find BEGIN PGP SIGNATURE/,
);
my $DATADIR = $0;
$DATADIR =~ s{[^/]+$}{};
if ($DATADIR) {
# invoked in some other dir
$DATADIR = "$DATADIR/data";
} else {
# current dir
$DATADIR = 'data';
}
plan skip_all => 'Data files not available'
unless -d $DATADIR;
plan tests => scalar keys %TESTS_BAD;
for my $filename (sort keys %TESTS_BAD) {
my $path = "$DATADIR/$filename";
my $deb822 = Lintian::Deb822->new;
try {
$deb822->read_file($path);
} catch {
my $error = $@;
my $fail_regex = $TESTS_BAD{$filename};
like($error, $fail_regex, $filename);
next;
}
fail("$path was parsed successfully");
}
# Local Variables:
# indent-tabs-mode: nil
# cperl-indent-level: 4
# End:
# vim: syntax=perl sw=4 sts=4 sr et
|