summaryrefslogtreecommitdiffstats
path: root/t/scripts/Lintian/Util/dctrl-parser.t
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:42:30 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:42:30 +0000
commit75808db17caf8b960b351e3408e74142f4c85aac (patch)
tree7989e9c09a4240248bf4658a22208a0a52d991c4 /t/scripts/Lintian/Util/dctrl-parser.t
parentInitial commit. (diff)
downloadlintian-75808db17caf8b960b351e3408e74142f4c85aac.tar.xz
lintian-75808db17caf8b960b351e3408e74142f4c85aac.zip
Adding upstream version 2.117.0.upstream/2.117.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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