Entry.pm 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. package Dpkg::Control::Tests::Entry;
  16. use strict;
  17. use warnings;
  18. our $VERSION = '1.00';
  19. use Dpkg::Gettext;
  20. use Dpkg::ErrorHandling;
  21. use Dpkg::Control;
  22. use parent qw(Dpkg::Control);
  23. =encoding utf8
  24. =head1 NAME
  25. Dpkg::Control::Tests::Entry - represents a test suite entry
  26. =head1 DESCRIPTION
  27. This object represents a test suite entry.
  28. =head1 METHODS
  29. All the methods of Dpkg::Control are available. Those listed below are either
  30. new or overridden with a different behavior.
  31. =over 4
  32. =item $entry = Dpkg::Control::Tests::Entry->new()
  33. Creates a new object. It does not represent a real control test entry
  34. until one has been successfully parsed or built from scratch.
  35. =cut
  36. sub new {
  37. my ($this, %opts) = @_;
  38. my $class = ref($this) || $this;
  39. my $self = Dpkg::Control->new(type => CTRL_TESTS, %opts);
  40. bless $self, $class;
  41. return $self;
  42. }
  43. =item $entry->parse($fh, $desc)
  44. Parse a control test entry from a filehandle. When called multiple times,
  45. the parsed fields are accumulated.
  46. Returns true if parsing was a success.
  47. =cut
  48. sub parse {
  49. my ($self, $fh, $desc) = @_;
  50. return if not $self->SUPER::parse($fh, $desc);
  51. if (not exists $self->{'Tests'} and not exists $self->{'Test-Command'}) {
  52. $self->parse_error($desc, g_('block lacks either %s or %s fields'),
  53. 'Tests', 'Test-Command');
  54. }
  55. return 1;
  56. }
  57. =back
  58. =head1 CHANGES
  59. =head2 Version 1.00 (dpkg 1.18.8)
  60. Mark the module as public.
  61. =cut
  62. 1;