"Fossies" - the Fresh Open Source Software Archive

Member "dpkg-1.19.7/scripts/t/Dpkg_Control_Fields.t" (19 Apr 2019, 8558 Bytes) of package /linux/misc/dpkg_1.19.7.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "Dpkg_Control_Fields.t": 1.19.4_vs_1.19.5.

    1 #!/usr/bin/perl
    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 use strict;
   17 use warnings;
   18 
   19 use Test::More;
   20 use Test::Dpkg qw(:paths);
   21 
   22 BEGIN {
   23     plan tests => 2438;
   24 
   25     use_ok('Dpkg::Control::Types');
   26     use_ok('Dpkg::Control::FieldsCore');
   27 }
   28 
   29 #my $datadir = test_get_data_path();
   30 
   31 my @src_dep_fields = qw(
   32     Build-Depends Build-Depends-Arch Build-Depends-Indep
   33     Build-Conflicts Build-Conflicts-Arch Build-Conflicts-Indep
   34 );
   35 my @bin_dep_normal_fields = qw(
   36     Pre-Depends Depends Recommends Suggests Enhances
   37 );
   38 my @bin_dep_union_fields = qw(
   39     Conflicts Breaks Replaces Provides Built-Using
   40 );
   41 my @bin_dep_fields = (@bin_dep_normal_fields, @bin_dep_union_fields);
   42 my @src_checksums = qw(
   43     Checksums-Md5 Checksums-Sha1 Checksums-Sha256
   44 );
   45 my @bin_checksums = qw(
   46     MD5sum SHA1 SHA256
   47 );
   48 my @src_files = (@src_checksums, qw(Files));
   49 my @bin_files = (qw(Filename Size), @bin_checksums);
   50 my @vcs_fields = qw(
   51     Vcs-Browser Vcs-Arch Vcs-Bzr Vcs-Cvs Vcs-Darcs Vcs-Git Vcs-Hg Vcs-Mtn
   52     Vcs-Svn
   53 );
   54 my @test_fields = qw(
   55     Testsuite Testsuite-Triggers
   56 );
   57 
   58 my %fields = (
   59     CTRL_INFO_SRC() => {
   60         name => 'debian/control source stanza',
   61         unordered => 1,
   62         fields => [
   63             qw(Bugs Homepage Description Origin Maintainer Uploaders
   64                Priority Section Source Standards-Version),
   65             @test_fields, @vcs_fields, @src_dep_fields
   66         ],
   67     },
   68     CTRL_INFO_PKG() => {
   69         name => 'debian/control binary stanza',
   70         unordered => 1,
   71         fields => [
   72             qw(Architecture Build-Essential Build-Profiles Built-For-Profiles
   73                Description Essential Homepage
   74                Installer-Menu-Item Kernel-Version Multi-Arch
   75                Package Package-Type Priority Section Subarchitecture
   76                Tag Task), @bin_dep_fields
   77         ],
   78     },
   79     CTRL_PKG_SRC() => {
   80         name => '.dsc',
   81         fields => [
   82             qw(Format Source Binary Architecture Version Origin Maintainer
   83                Uploaders Homepage Description Standards-Version),
   84             @vcs_fields, @test_fields, @src_dep_fields,
   85             qw(Package-List),
   86             @src_files
   87         ],
   88     },
   89     CTRL_PKG_DEB() => {
   90         name => 'DEBIAN/control',
   91         fields => [
   92             qw(Package Package-Type Source Version Built-Using Kernel-Version
   93                Built-For-Profiles Auto-Built-Package Architecture
   94                Subarchitecture Installer-Menu-Item
   95                Build-Essential Essential Origin Bugs
   96                Maintainer Installed-Size), @bin_dep_fields,
   97             qw(Section Priority Multi-Arch Homepage Description Tag Task)
   98         ],
   99     },
  100     CTRL_INDEX_SRC() => {
  101         name => 'Sources',
  102         fields => [
  103             qw(Format Package Binary Architecture Version Priority Section
  104                Origin Maintainer Uploaders Homepage Description
  105                Standards-Version),
  106             @vcs_fields, @test_fields, @src_dep_fields,
  107             qw(Package-List Directory),
  108             @src_files
  109         ],
  110     },
  111     CTRL_INDEX_PKG() => {
  112         name => 'Packages',
  113         fields => [
  114             qw(Package Package-Type Source Version Built-Using Kernel-Version
  115                Built-For-Profiles Auto-Built-Package Architecture
  116                Subarchitecture Installer-Menu-Item
  117                Build-Essential Essential Origin Bugs
  118                Maintainer Installed-Size), @bin_dep_fields, @bin_files,
  119             qw(Section Priority Multi-Arch Homepage Description Tag Task)
  120         ],
  121     },
  122     CTRL_REPO_RELEASE() => {
  123         name => 'Release',
  124         fields => [
  125             qw(Origin Label Suite Codename Changelogs Date Valid-Until
  126                Architectures Components Description),
  127             @bin_checksums
  128         ],
  129     },
  130     CTRL_CHANGELOG() => {
  131         name => 'debian/changelog',
  132         fields => [
  133             qw(Source Binary-Only Version Distribution Urgency Maintainer
  134                Timestamp Date Closes Changes)
  135         ],
  136     },
  137     CTRL_COPYRIGHT_HEADER() => {
  138         name => 'debian/copyright Format stanza',
  139         fields => [
  140             qw(Format Upstream-Name Upstream-Contact Source Disclaimer Comment
  141                License Copyright)
  142         ],
  143     },
  144     CTRL_COPYRIGHT_FILES() => {
  145         name => 'debian/copyright Files stanza',
  146         fields => [
  147             qw(Files Copyright License Comment)
  148         ],
  149     },
  150     CTRL_COPYRIGHT_LICENSE() => {
  151         name => 'debian/copyright License stanza',
  152         fields => [
  153             qw(License Comment)
  154         ],
  155     },
  156     CTRL_TESTS() => {
  157         name => 'debian/tests/control',
  158         unordered => 1,
  159         fields => [
  160             qw(Classes Depends Features Restrictions Test-Command Tests
  161                Tests-Directory)
  162         ],
  163     },
  164     CTRL_FILE_BUILDINFO() => {
  165         name => '.buildinfo',
  166         fields => [
  167             qw(Format Source Binary Architecture Version Binary-Only-Changes),
  168             @src_checksums,
  169             qw(Build-Origin Build-Architecture Build-Kernel-Version
  170                Build-Date Build-Path Build-Tainted-By
  171                Installed-Build-Depends Environment)
  172         ],
  173     },
  174     CTRL_FILE_CHANGES() => {
  175         name => '.changes',
  176         fields => [
  177             qw(Format Date Source Binary Binary-Only Built-For-Profiles
  178                Architecture Version Distribution Urgency Maintainer
  179                Changed-By Description Closes Changes),
  180             @src_files
  181         ],
  182     },
  183     CTRL_FILE_VENDOR() => {
  184         name => 'dpkg origin',
  185         unordered => 1,
  186         fields => [
  187             qw(Bugs Parent Vendor Vendor-Url)
  188         ],
  189     },
  190     CTRL_FILE_STATUS() => {
  191         name => 'dpkg status',
  192         fields => [
  193             qw(Package Essential Status Priority Section Installed-Size
  194                Origin Maintainer Bugs Architecture Multi-Arch Source
  195                Version Config-Version
  196                Replaces Provides Depends Pre-Depends
  197                Recommends Suggests Breaks Conflicts Enhances
  198                Conffiles Description Triggers-Pending Triggers-Awaited
  199                Auto-Built-Package Build-Essential Built-For-Profiles
  200                Built-Using Homepage Installer-Menu-Item Kernel-Version
  201                Package-Type Subarchitecture Tag Task)
  202         ],
  203     },
  204 );
  205 
  206 is_deeply([ field_list_src_dep() ],
  207           [ @src_dep_fields ],
  208           'List of build dependencies');
  209 is_deeply([ field_list_pkg_dep() ],
  210           [ @bin_dep_fields ],
  211           'List of build dependencies');
  212 
  213 is(field_capitalize('invented-field'), 'Invented-Field',
  214    'Field Invented-Field capitalization');
  215 ok(!field_is_official('invented-field'),
  216    'Field Invented-Field is not official');
  217 
  218 my %known_fields;
  219 foreach my $type (sort keys %fields) {
  220     if (not $fields{$type}->{unordered}) {
  221         is_deeply([ field_ordered_list($type) ], $fields{$type}->{fields},
  222                   "List of $fields{$type}->{name} fields");
  223     }
  224 
  225     foreach my $field (@{$fields{$type}->{fields}}) {
  226         $known_fields{$field} = 1;
  227     }
  228 }
  229 
  230 foreach my $field (sort keys %known_fields) {
  231     is(field_capitalize($field), $field, "Field $field capitalization");
  232     is(field_capitalize(lc $field), $field, "Field lc($field) capitalization");
  233     is(field_capitalize(uc $field), $field, "Field uc($field) capitalization");
  234 
  235     ok(field_is_official($field), "Field $field is official");
  236     ok(field_is_official(lc $field), "Field lc($field) is official");
  237     ok(field_is_official(uc $field), "Field uc($field) is official");
  238 }
  239 
  240 foreach my $type (sort keys %fields) {
  241     my %allowed_fields = map { $_ => 1 } @{$fields{$type}->{fields}};
  242 
  243     foreach my $field (sort keys %known_fields) {
  244         if ($allowed_fields{$field}) {
  245             ok(field_is_allowed_in($field, $type),
  246                "Field $field allowed for type $type");
  247         } else {
  248             ok(!field_is_allowed_in($field, $type),
  249                "Field $field not allowed for type $type");
  250         }
  251     }
  252 }