doc: Move Perl version baseline as the first perl coding style subsection
[dpkg.git] / scripts / t / Dpkg_Control_Tests.t
blob27042dcfccf0658ad398329126e90af64e47271f
1 #!/usr/bin/perl
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 use strict;
17 use warnings;
19 use Test::More tests => 5;
20 use Test::Dpkg qw(:paths);
22 BEGIN {
23 use_ok('Dpkg::Control::Tests');
26 my $datadir = test_get_data_path();
28 sub parse_tests {
29 my $path = shift;
31 my $tests = Dpkg::Control::Tests->new();
32 eval {
33 $tests->load($path);
35 } or return;
37 return $tests;
40 my $tests;
42 $tests = parse_tests("$datadir/tests-missing-fields");
43 is($tests, undef, 'autopkgtest missing required fields');
45 $tests = parse_tests("$datadir/tests-plain-text");
46 is($tests, undef, 'autopkgtest is not in deb822 format');
48 my $expected = <<'TESTS';
49 Tests: aaa, bbb, ccc
51 Tests: danger, warning
52 Restrictions: rw-build-tree, needs-root, breaks-testbed
54 Tests: depends
55 Depends: @, @builddeps@, extra-package
57 Tests: dir
58 Tests-Directory: .
60 Tests: feature
62 Tests: class
63 Classes: self-test
65 Test-Command: command arg1 arg2
67 TESTS
69 $tests = parse_tests("$datadir/tests-valid");
70 ok(defined $tests, 'Valid autopkgtest control file');
71 is($tests->output(), $expected, 'autopkgtest control file dumped');