chiark / gitweb /
lib/dpkg/tarfn.c: Kludge `tar_header_decode' to handle spurious `errno'.
[dpkg] / scripts / t / Dpkg_Control_Tests.t
1 #!/usr/bin/perl
2 #
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.
7 #
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.
12 #
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/>.
15
16 use strict;
17 use warnings;
18
19 use Test::More tests => 5;
20 use Test::Dpkg qw(:paths);
21
22 BEGIN {
23     use_ok('Dpkg::Control::Tests');
24 }
25
26 my $datadir = test_get_data_path('t/Dpkg_Control_Tests');
27
28 sub parse_tests {
29     my $path = shift;
30
31     my $tests = Dpkg::Control::Tests->new();
32     eval {
33         $tests->load($path);
34         1;
35     } or return;
36
37     return $tests;
38 }
39
40 my $tests;
41
42 $tests = parse_tests("$datadir/tests-missing-fields");
43 is($tests, undef, 'autopkgtest missing required fields');
44
45 $tests = parse_tests("$datadir/tests-plain-text");
46 is($tests, undef, 'autopkgtest is not in deb822 format');
47
48 my $expected = <<'TESTS';
49 Tests: aaa, bbb, ccc
50
51 Tests: danger, warning
52 Restrictions: rw-build-tree, needs-root, breaks-testbed
53
54 Tests: depends
55 Depends: @, @builddeps@, extra-package
56
57 Tests: dir
58 Tests-Directory: .
59
60 Tests: feature
61
62 Tests: class
63 Classes: self-test
64
65 Test-Command: command arg1 arg2
66
67 TESTS
68
69 $tests = parse_tests("$datadir/tests-valid");
70 ok(defined $tests, 'Valid autopkgtest control file');
71 is($tests->output(), $expected, 'autopkgtest control file dumped');