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.
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.
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/>.
20 use Test
::Dpkg
qw(:paths);
25 use_ok
('Dpkg::Control::Types');
26 use_ok
('Dpkg::Control::FieldsCore');
27 use_ok
('Dpkg::Control');
30 #my $datadir = test_get_data_path();
32 my @src_dep_fields = qw(
40 my @bin_dep_normal_fields = qw(
47 my @bin_dep_union_fields = qw(
55 my @bin_dep_fields = (
56 @bin_dep_normal_fields,
57 @bin_dep_union_fields,
59 my @src_checksums = qw(
64 my @bin_checksums = qw(
100 name
=> 'debian/control source stanza',
125 name
=> 'debian/control binary stanza',
178 name
=> 'DEBIAN/control',
274 CTRL_REPO_RELEASE
() => {
289 No-Support-for-Architecture-all
297 CTRL_CHANGELOG
() => {
298 name
=> 'debian/changelog',
314 CTRL_COPYRIGHT_HEADER
() => {
315 name
=> 'debian/copyright Format stanza',
329 CTRL_COPYRIGHT_FILES
() => {
330 name
=> 'debian/copyright Files stanza',
340 CTRL_COPYRIGHT_LICENSE
() => {
341 name
=> 'debian/copyright License stanza',
350 name
=> 'debian/tests/control',
364 CTRL_FILE_BUILDINFO
() => {
365 name
=> '.buildinfo',
383 Installed-Build-Depends
388 CTRL_FILE_CHANGES
() => {
411 CTRL_FILE_VENDOR
() => {
412 name
=> 'dpkg origin',
422 CTRL_FILE_STATUS
() => {
423 name
=> 'dpkg status',
471 is_deeply
([ field_list_src_dep
() ],
473 'List of build dependencies');
474 is_deeply
([ field_list_pkg_dep
() ],
476 'List of build dependencies');
478 is
(field_capitalize
('invented-field'), 'Invented-Field',
479 'Field Invented-Field capitalization');
480 ok
(!field_is_official
('invented-field'),
481 'Field Invented-Field is not official');
484 foreach my $type (sort keys %fields) {
485 if (not $fields{$type}->{unordered
}) {
486 is_deeply
([ field_ordered_list
($type) ], $fields{$type}->{fields
},
487 "List of $fields{$type}->{name} fields");
490 foreach my $field (@
{$fields{$type}->{fields
}}) {
491 $known_fields{$field} = 1;
495 foreach my $field (sort keys %known_fields) {
496 is
(field_capitalize
($field), $field, "Field $field capitalization");
497 is
(field_capitalize
(lc $field), $field, "Field lc($field) capitalization");
498 is
(field_capitalize
(uc $field), $field, "Field uc($field) capitalization");
500 ok
(field_is_official
($field), "Field $field is official");
501 ok
(field_is_official
(lc $field), "Field lc($field) is official");
502 ok
(field_is_official
(uc $field), "Field uc($field) is official");
505 foreach my $type (sort keys %fields) {
506 my %allowed_fields = map { $_ => 1 } @
{$fields{$type}->{fields
}};
508 foreach my $field (sort keys %known_fields) {
509 if ($allowed_fields{$field}) {
510 ok
(field_is_allowed_in
($field, $type),
511 "Field $field allowed for type $fields{$type}->{name}");
513 ok
(!field_is_allowed_in
($field, $type),
514 "Field $field not allowed for type $fields{$type}->{name}");
519 # Check deb822 field parsers
521 my $ctrl = Dpkg
::Control
->new(type
=> CTRL_DEB
);
523 my ($source, $version);
525 $ctrl->{Package
} = 'test-binary';
526 $ctrl->{Version
} = '2.0-1';
527 $ctrl->{Source
} = 'test-source (1.0)';
528 ($source, $version) = field_parse_binary_source
($ctrl);
529 is
($source, 'test-source', 'Source package from binary w/ Source field');
530 is
($version, '1.0', 'Source version from binary w/ Source field');
532 $ctrl->{Source
} = 'test-source';
533 ($source, $version) = field_parse_binary_source
($ctrl);
534 is
($source, 'test-source', 'Source package from binary w/ Source field w/o version');
535 is
($version, '2.0-1', 'Source version from binary w/ Source field w/o version');
537 delete $ctrl->{Source
};
538 ($source, $version) = field_parse_binary_source
($ctrl);
539 is
($source, 'test-binary', 'Source package from binary w/o Source field');
540 is
($version, '2.0-1', 'Source version from binary w/o Source field');