| File: | Dpkg/Control/Tests/Entry.pm |
| Coverage: | 95.8% |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | # Copyright © 2016 Guillem Jover <guillem@debian.org> | ||||||
| 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 | =encoding utf8 | ||||||
| 17 | |||||||
| 18 - 26 | =head1 NAME Dpkg::Control::Tests::Entry - represents a test suite entry =head1 DESCRIPTION This class represents a test suite entry. =cut | ||||||
| 27 | |||||||
| 28 | package Dpkg::Control::Tests::Entry 1.00; | ||||||
| 29 | |||||||
| 30 | 3 3 3 | 7 3 42 | use strict; | ||||
| 31 | 3 3 3 | 5 2 79 | use warnings; | ||||
| 32 | |||||||
| 33 | 3 3 3 | 8 3 110 | use Dpkg::Gettext; | ||||
| 34 | 3 3 3 | 7 3 115 | use Dpkg::ErrorHandling; | ||||
| 35 | 3 3 3 | 7 2 146 | use Dpkg::Control; | ||||
| 36 | |||||||
| 37 | 3 3 3 | 8 2 13 | use parent qw(Dpkg::Control); | ||||
| 38 | |||||||
| 39 - 51 | =head1 METHODS All the methods of L<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 | ||||||
| 52 | |||||||
| 53 | sub new { | ||||||
| 54 | 36 | 1 | 32 | my ($this, %opts) = @_; | |||
| 55 | 36 | 90 | my $class = ref($this) || $this; | ||||
| 56 | |||||||
| 57 | 36 | 69 | my $self = Dpkg::Control->new(type => CTRL_TESTS, %opts); | ||||
| 58 | 36 | 38 | bless $self, $class; | ||||
| 59 | 36 | 55 | return $self; | ||||
| 60 | } | ||||||
| 61 | |||||||
| 62 - 69 | =item $entry->parse($fh, $desc) Parse a control test entry from a filehandle. When called multiple times, the parsed fields are accumulated. Returns true if parsing was a success. =cut | ||||||
| 70 | |||||||
| 71 | sub parse { | ||||||
| 72 | 36 | 1 | 40 | my ($self, $fh, $desc) = @_; | |||
| 73 | |||||||
| 74 | 36 | 70 | return if not $self->SUPER::parse($fh, $desc); | ||||
| 75 | |||||||
| 76 | 30 | 39 | if (not exists $self->{'Tests'} and not exists $self->{'Test-Command'}) { | ||||
| 77 | 3 | 8 | $self->parse_error($desc, g_('stanza lacks either %s or %s fields'), | ||||
| 78 | 'Tests', 'Test-Command'); | ||||||
| 79 | } | ||||||
| 80 | |||||||
| 81 | 27 | 40 | return 1; | ||||
| 82 | } | ||||||
| 83 | |||||||
| 84 | =back | ||||||
| 85 | |||||||
| 86 - 92 | =head1 CHANGES =head2 Version 1.00 (dpkg 1.18.8) Mark the module as public. =cut | ||||||
| 93 | |||||||
| 94 | 1; | ||||||