summaryrefslogtreecommitdiffstats
path: root/t/scripts/Lintian/Util/dctrl-parser.t
diff options
context:
space:
mode:
Diffstat (limited to 't/scripts/Lintian/Util/dctrl-parser.t')
-rwxr-xr-xt/scripts/Lintian/Util/dctrl-parser.t64
1 files changed, 64 insertions, 0 deletions
diff --git a/t/scripts/Lintian/Util/dctrl-parser.t b/t/scripts/Lintian/Util/dctrl-parser.t
new file mode 100755
index 0000000..36d9961
--- /dev/null
+++ b/t/scripts/Lintian/Util/dctrl-parser.t
@@ -0,0 +1,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