File Coverage

blib/lib/Dpkg/Control/Tests/Entry.pm
Criterion Covered Total %
statement 28 28 100.0
branch 4 4 100.0
condition 4 6 66.6
subroutine 8 8 100.0
pod 2 2 100.0
total 46 48 95.8


line stmt bran cond sub pod time code
1             # Copyright © 2016 Guillem Jover
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 .
15              
16             package Dpkg::Control::Tests::Entry;
17              
18 1     1   7 use strict;
  1         2  
  1         30  
19 1     1   5 use warnings;
  1         2  
  1         40  
20              
21             our $VERSION = '1.00';
22              
23 1     1   5 use Dpkg::Gettext;
  1         1  
  1         71  
24 1     1   7 use Dpkg::ErrorHandling;
  1         2  
  1         90  
25 1     1   7 use Dpkg::Control;
  1         2  
  1         85  
26              
27 1     1   7 use parent qw(Dpkg::Control);
  1         1  
  1         8  
28              
29             =encoding utf8
30              
31             =head1 NAME
32              
33             Dpkg::Control::Tests::Entry - represents a test suite entry
34              
35             =head1 DESCRIPTION
36              
37             This class represents a test suite entry.
38              
39             =head1 METHODS
40              
41             All the methods of Dpkg::Control are available. Those listed below are either
42             new or overridden with a different behavior.
43              
44             =over 4
45              
46             =item $entry = Dpkg::Control::Tests::Entry->new()
47              
48             Creates a new object. It does not represent a real control test entry
49             until one has been successfully parsed or built from scratch.
50              
51             =cut
52              
53             sub new {
54 12     12 1 24 my ($this, %opts) = @_;
55 12   33     35 my $class = ref($this) || $this;
56              
57 12         41 my $self = Dpkg::Control->new(type => CTRL_TESTS, %opts);
58 12         24 bless $self, $class;
59 12         30 return $self;
60             }
61              
62             =item $entry->parse($fh, $desc)
63              
64             Parse a control test entry from a filehandle. When called multiple times,
65             the parsed fields are accumulated.
66              
67             Returns true if parsing was a success.
68              
69             =cut
70              
71             sub parse {
72 12     12 1 24 my ($self, $fh, $desc) = @_;
73              
74 12 100       33 return if not $self->SUPER::parse($fh, $desc);
75              
76 10 100 100     28 if (not exists $self->{'Tests'} and not exists $self->{'Test-Command'}) {
77 1         5 $self->parse_error($desc, g_('block lacks either %s or %s fields'),
78             'Tests', 'Test-Command');
79             }
80              
81 9         34 return 1;
82             }
83              
84             =back
85              
86             =head1 CHANGES
87              
88             =head2 Version 1.00 (dpkg 1.18.8)
89              
90             Mark the module as public.
91              
92             =cut
93              
94             1;