summaryrefslogtreecommitdiff
path: root/scripts/t/Dpkg_Control_Tests.t
blob: 9c14a2e4ec2312ba7f22260339cee78a50d607a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/perl
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

use strict;
use warnings;

use Test::More tests => 5;
use Test::Dpkg qw(:paths);

BEGIN {
    use_ok('Dpkg::Control::Tests');
}

my $datadir = test_get_data_path('t/Dpkg_Control_Tests');

sub parse_tests {
    my $path = shift;

    my $tests = Dpkg::Control::Tests->new();
    eval {
        $tests->load($path);
        1;
    } or return;

    return $tests;
}

my $tests;

$tests = parse_tests("$datadir/tests-missing-fields");
is($tests, undef, 'autopkgtest missing required fields');

$tests = parse_tests("$datadir/tests-plain-text");
is($tests, undef, 'autopkgtest is not in deb822 format');

my $expected = <<'TESTS';
Tests: aaa, bbb, ccc

Tests: danger, warning
Restrictions: rw-build-tree, needs-root, breaks-testbed

Tests: depends
Depends: @, @builddeps@, extra-package

Tests: dir
Tests-Directory: .

Tests: feature

Tests: class
Classes: self-test

Test-Command: command arg1 arg2

TESTS

$tests = parse_tests("$datadir/tests-valid");
ok(defined $tests, 'Valid autopkgtest control file');
is($tests->output(), $expected, 'autopkgtest control file dumped');