diff options
author | Guillem Jover <guillem@debian.org> | 2016-05-13 17:10:33 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2016-07-03 18:44:24 +0200 |
commit | 0d159ba9b5da8bd5dfcb9e9110ba3e4c2867b0fe (patch) | |
tree | 2d06cb942ad9152ed4ab0dbfc871717408d0d649 /scripts/Dpkg/Control | |
parent | fc55edbf31dc9d8649229fdca441cb63844424d9 (diff) | |
download | dpkg-0d159ba9b5da8bd5dfcb9e9110ba3e4c2867b0fe.tar.gz |
Dpkg::Control: Add new autopkgtest control files support
Add new CTRL_TESTS control types, new Dpkg::Control::Tests and
Dpkg::Control::Tests::Entry modules, add support for the fields that
can appear on these control files, and update Dpkg::Index to handle
them as well.
[niels@thykier.net: Fix logic inversion. ]
Diffstat (limited to 'scripts/Dpkg/Control')
-rw-r--r-- | scripts/Dpkg/Control/FieldsCore.pm | 24 | ||||
-rw-r--r-- | scripts/Dpkg/Control/Tests.pm | 83 | ||||
-rw-r--r-- | scripts/Dpkg/Control/Tests/Entry.pm | 91 | ||||
-rw-r--r-- | scripts/Dpkg/Control/Types.pm | 3 |
4 files changed, 200 insertions, 1 deletions
diff --git a/scripts/Dpkg/Control/FieldsCore.pm b/scripts/Dpkg/Control/FieldsCore.pm index 1f01ae0b0..0c7ce4b1f 100644 --- a/scripts/Dpkg/Control/FieldsCore.pm +++ b/scripts/Dpkg/Control/FieldsCore.pm @@ -153,6 +153,10 @@ our %FIELDS = ( 'Changes' => { allowed => ALL_CHANGES, }, + 'Classes' => { + allowed => CTRL_TESTS, + separator => FIELD_SEP_COMMA, + }, 'Closes' => { allowed => ALL_CHANGES, separator => FIELD_SEP_SPACE, @@ -187,7 +191,7 @@ our %FIELDS = ( allowed => ALL_CHANGES | CTRL_REPO_RELEASE, }, 'Depends' => { - allowed => ALL_PKG, + allowed => ALL_PKG | CTRL_TESTS, separator => FIELD_SEP_COMMA, dependency => 'normal', dep_order => 2, @@ -213,6 +217,10 @@ our %FIELDS = ( 'Essential' => { allowed => ALL_PKG, }, + 'Features' => { + allowed => CTRL_TESTS, + separator => FIELD_SEP_SPACE, + }, 'Filename' => { allowed => CTRL_INDEX_PKG, separator => FIELD_SEP_LINE | FIELD_SEP_SPACE, @@ -291,6 +299,10 @@ our %FIELDS = ( dependency => 'union', dep_order => 8, }, + 'Restrictions' => { + allowed => CTRL_TESTS, + separator => FIELD_SEP_SPACE, + }, 'Section' => { allowed => CTRL_INFO_SRC | CTRL_INDEX_SRC | ALL_PKG, }, @@ -328,6 +340,16 @@ our %FIELDS = ( 'Task' => { allowed => ALL_PKG, }, + 'Test-Command' => { + allowed => CTRL_TESTS, + }, + 'Tests' => { + allowed => CTRL_TESTS, + separator => FIELD_SEP_SPACE, + }, + 'Tests-Directory' => { + allowed => CTRL_TESTS, + }, 'Testsuite' => { allowed => ALL_SRC, separator => FIELD_SEP_COMMA, diff --git a/scripts/Dpkg/Control/Tests.pm b/scripts/Dpkg/Control/Tests.pm new file mode 100644 index 000000000..439eee8c8 --- /dev/null +++ b/scripts/Dpkg/Control/Tests.pm @@ -0,0 +1,83 @@ +# Copyright © 2016 Guillem Jover <guillem@debian.org> +# +# 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/>. + +package Dpkg::Control::Tests; + +use strict; +use warnings; + +our $VERSION = '1.00'; + +use Dpkg::Control; +use Dpkg::Control::Tests::Entry; +use Dpkg::Index; + +use parent qw(Dpkg::Index); + +=encoding utf8 + +=head1 NAME + +Dpkg::Control::Tests - parse files like debian/tests/control + +=head1 DESCRIPTION + +It provides an object to access data of files that follow the same +syntax as F<debian/tests/control>. + +=head1 METHODS + +All the methods of Dpkg::Index are available. Those listed below are either +new or overridden with a different behavior. + +=over 4 + +=item $c = Dpkg::Control::Tests->new(%opts) + +Create a new Dpkg::Control::Tests object, which inherits from Dpkg::Index. + +=cut + +sub new { + my ($this, %opts) = @_; + my $class = ref($this) || $this; + my $self = Dpkg::Index->new(type => CTRL_TESTS, %opts); + + return bless $self, $class; +} + +=item $item = $tests->new_item() + +Creates a new item. + +=cut + +sub new_item { + my $self = shift; + + return Dpkg::Control::Tests::Entry->new(); +} + +=back + +=head1 CHANGES + +=head2 Version 1.00 (dpkg 1.18.8) + +Mark the module as public. + +=cut + +1; diff --git a/scripts/Dpkg/Control/Tests/Entry.pm b/scripts/Dpkg/Control/Tests/Entry.pm new file mode 100644 index 000000000..392493c2a --- /dev/null +++ b/scripts/Dpkg/Control/Tests/Entry.pm @@ -0,0 +1,91 @@ +# Copyright © 2016 Guillem Jover <guillem@debian.org> +# +# 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/>. + +package Dpkg::Control::Tests::Entry; + +use strict; +use warnings; + +our $VERSION = '1.00'; + +use Dpkg::Gettext; +use Dpkg::ErrorHandling; +use Dpkg::Control; + +use parent qw(Dpkg::Control); + +=encoding utf8 + +=head1 NAME + +Dpkg::Control::Tests::Entry - represents a test suite entry + +=head1 DESCRIPTION + +This object represents a test suite entry. + +=head1 METHODS + +All the methods of Dpkg::Control are available. Those listed below are either +new or overridden with a different behavior. + +=over 4 + +=item $entry = Dpkg::Control::Tests::Entry->new() + +Creates a new object. It does not represent a real control test entry +until one has been successfully parsed or built from scratch. + +=cut + +sub new { + my ($this, %opts) = @_; + my $class = ref($this) || $this; + + my $self = Dpkg::Control->new(type => CTRL_TESTS, %opts); + bless $self, $class; + return $self; +} + +=item $entry->parse($fh, $desc) + +Parse a control test entry from a filehandle. + +=cut + +sub parse { + my ($self, $fh, $desc) = @_; + + return if not $self->SUPER::parse($fh, $desc); + + if (not exists $self->{'Tests'} and not exists $self->{'Test-Command'}) { + $self->parse_error($desc, g_('block lacks either %s or %s fields'), + 'Tests', 'Test-Command'); + } + + return 1; +} + +=back + +=head1 CHANGES + +=head2 Version 1.00 (dpkg 1.18.8) + +Mark the module as public. + +=cut + +1; diff --git a/scripts/Dpkg/Control/Types.pm b/scripts/Dpkg/Control/Types.pm index 938659bfb..e144dd942 100644 --- a/scripts/Dpkg/Control/Types.pm +++ b/scripts/Dpkg/Control/Types.pm @@ -33,6 +33,7 @@ our @EXPORT = qw( CTRL_COPYRIGHT_HEADER CTRL_COPYRIGHT_FILES CTRL_COPYRIGHT_LICENSE + CTRL_TESTS ); use Exporter qw(import); @@ -83,6 +84,8 @@ use constant { CTRL_COPYRIGHT_FILES => 4096, # License control block in debian/copyright. CTRL_COPYRIGHT_LICENSE => 8192, + # Package test suite control file in debian/tests/control. + CTRL_TESTS => 16384, }; =head1 CHANGES |