dpkg (1.18.25) stretch; urgency=medium
[dpkg] / scripts / t / Dpkg_Control_Tests.t
CommitLineData
1479465f
GJ
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
16use strict;
17use warnings;
18
19use Test::More tests => 5;
20use Test::Dpkg qw(:paths);
21
22BEGIN {
23 use_ok('Dpkg::Control::Tests');
24}
25
26my $datadir = test_get_data_path('t/Dpkg_Control_Tests');
27
28sub 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
40my $tests;
41
42$tests = parse_tests("$datadir/tests-missing-fields");
43is($tests, undef, 'autopkgtest missing required fields');
44
45$tests = parse_tests("$datadir/tests-plain-text");
46is($tests, undef, 'autopkgtest is not in deb822 format');
47
48my $expected = <<'TESTS';
49Tests: aaa, bbb, ccc
50
51Tests: danger, warning
52Restrictions: rw-build-tree, needs-root, breaks-testbed
53
54Tests: depends
55Depends: @, @builddeps@, extra-package
56
57Tests: dir
58Tests-Directory: .
59
60Tests: feature
61
62Tests: class
63Classes: self-test
64
65Test-Command: command arg1 arg2
66
67TESTS
68
69$tests = parse_tests("$datadir/tests-valid");
70ok(defined $tests, 'Valid autopkgtest control file');
71is($tests->output(), $expected, 'autopkgtest control file dumped');