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/>.
19 use Test
::More tests
=> 34;
22 $ENV{DEB_BUILD_ARCH
} = 'amd64';
23 $ENV{DEB_HOST_ARCH
} = 'amd64';
24 use_ok
('Dpkg::BuildFlags');
27 my $bf = Dpkg
::BuildFlags
->new();
29 ok
($bf->has('CPPFLAGS'), 'CPPFLAGS is present');
30 is
($bf->get_origin('CPPFLAGS'), 'vendor', 'CPPFLAGS has a vendor origin');
32 $bf->set('DPKGFLAGS', '-Wflag -On -fsome', 'system');
33 is
($bf->get('DPKGFLAGS'), '-Wflag -On -fsome', 'get flag');
34 is
($bf->get_origin('DPKGFLAGS'), 'system', 'flag has a system origin');
35 ok
(!$bf->is_maintainer_modified('DPKGFLAGS'), 'set marked flag as non-maint modified');
37 $bf->strip('DPKGFLAGS', '-On', 'user', undef);
38 is
($bf->get('DPKGFLAGS'), '-Wflag -fsome', 'get stripped flag');
39 is
($bf->get_origin('DPKGFLAGS'), 'user', 'flag has a user origin');
40 ok
(!$bf->is_maintainer_modified('DPKGFLAGS'), 'strip marked flag as non-maint modified');
48 value
=> '-fdupe -fdupe',
52 value
=> '-Wa -fdupe -fdupe -Wb',
56 value
=> '-fdupe -Wa -Wb -fdupe',
60 value
=> '-fdupe -Wa -fdupe -Wb',
64 value
=> '-Wa -fdupe -Wb -fdupe',
70 foreach my $test (@strip_tests) {
71 $bf->set('DPKGSTRIPFLAGS', $test->{value
}, 'system');
72 $bf->strip('DPKGSTRIPFLAGS', $test->{strip
}, 'user', undef);
73 is
($bf->get('DPKGSTRIPFLAGS'), $test->{exp},
74 "strip flag '$test->{strip}' from '$test->{value}' to '$test->{exp}'");
77 $bf->append('DPKGFLAGS', '-Wl,other', 'vendor', 0);
78 is
($bf->get('DPKGFLAGS'), '-Wflag -fsome -Wl,other', 'get appended flag');
79 is
($bf->get_origin('DPKGFLAGS'), 'vendor', 'flag has a vendor origin');
80 ok
(!$bf->is_maintainer_modified('DPKGFLAGS'), 'append marked flag as non-maint modified');
82 $bf->prepend('DPKGFLAGS', '-Idir', 'env', 1);
83 is
($bf->get('DPKGFLAGS'), '-Idir -Wflag -fsome -Wl,other', 'get prepended flag');
84 is
($bf->get_origin('DPKGFLAGS'), 'env', 'flag has an env origin');
85 ok
($bf->is_maintainer_modified('DPKGFLAGS'), 'prepend marked flag as maint modified');
87 my %known_features = (
107 reproducible
=> [ qw(
123 is_deeply
([ sort $bf->get_feature_areas() ], [ sort keys %known_features ],
124 'supported feature areas');
126 foreach my $area (sort keys %known_features) {
127 ok
($bf->has_features($area), "has feature area $area");
128 my %features = $bf->get_features($area);
129 is_deeply
([ sort keys %features ],
130 $known_features{$area},
131 "supported features for area $area");
134 # TODO: Add more test cases.