diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 00:45:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 00:45:20 +0000 |
commit | 9a08cbfcc1ef900a04580f35afe2a4592d7d6030 (patch) | |
tree | 004cc7027bca2f2c0bcb5806527c8e0c48df2d6e /scripts/t/Dpkg_Control_Tests | |
parent | Initial commit. (diff) | |
download | dpkg-upstream.tar.xz dpkg-upstream.zip |
Adding upstream version 1.19.8.upstream/1.19.8upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | scripts/t/Dpkg_Control_Tests.t | 71 | ||||
-rw-r--r-- | scripts/t/Dpkg_Control_Tests/tests-missing-fields | 7 | ||||
-rw-r--r-- | scripts/t/Dpkg_Control_Tests/tests-plain-text | 6 | ||||
-rw-r--r-- | scripts/t/Dpkg_Control_Tests/tests-valid | 18 |
4 files changed, 102 insertions, 0 deletions
diff --git a/scripts/t/Dpkg_Control_Tests.t b/scripts/t/Dpkg_Control_Tests.t new file mode 100644 index 0000000..27042dc --- /dev/null +++ b/scripts/t/Dpkg_Control_Tests.t @@ -0,0 +1,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(); + +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'); diff --git a/scripts/t/Dpkg_Control_Tests/tests-missing-fields b/scripts/t/Dpkg_Control_Tests/tests-missing-fields new file mode 100644 index 0000000..7f7794d --- /dev/null +++ b/scripts/t/Dpkg_Control_Tests/tests-missing-fields @@ -0,0 +1,7 @@ +Tests: aaa + +Test-Command: command + +Other: + +Tests: bbb diff --git a/scripts/t/Dpkg_Control_Tests/tests-plain-text b/scripts/t/Dpkg_Control_Tests/tests-plain-text new file mode 100644 index 0000000..a29d388 --- /dev/null +++ b/scripts/t/Dpkg_Control_Tests/tests-plain-text @@ -0,0 +1,6 @@ +This is a plain text file +that does not contain + + any of the expected fields nor values + +and should fail to load. diff --git a/scripts/t/Dpkg_Control_Tests/tests-valid b/scripts/t/Dpkg_Control_Tests/tests-valid new file mode 100644 index 0000000..c0ad60b --- /dev/null +++ b/scripts/t/Dpkg_Control_Tests/tests-valid @@ -0,0 +1,18 @@ +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 +Features: + +Tests: class +Classes: self-test + +Test-Command: command arg1 arg2 |