Commit | Line | Data |
---|---|---|
1479465f GJ |
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 tests => 15; | |
20 | ||
21 | BEGIN { | |
22 | use_ok('Dpkg::BuildFlags'); | |
23 | } | |
24 | ||
25 | my $bf = Dpkg::BuildFlags->new(); | |
26 | ||
27 | ok($bf->has('CPPFLAGS'), 'CPPFLAGS is present'); | |
28 | is($bf->get_origin('CPPFLAGS'), 'vendor', 'CPPFLAGS has a vendor origin'); | |
29 | ||
30 | $bf->set('DPKGFLAGS', '-Wflag -On -fsome', 'system'); | |
31 | is($bf->get('DPKGFLAGS'), '-Wflag -On -fsome', 'get flag'); | |
32 | is($bf->get_origin('DPKGFLAGS'), 'system', 'flag has a system origin'); | |
33 | ok(!$bf->is_maintainer_modified('DPKGFLAGS'), 'set marked flag as non-maint modified'); | |
34 | ||
35 | $bf->strip('DPKGFLAGS', '-On', 'user', undef); | |
36 | is($bf->get('DPKGFLAGS'), '-Wflag -fsome', 'get stripped flag'); | |
37 | is($bf->get_origin('DPKGFLAGS'), 'user', 'flag has a user origin'); | |
38 | ok(!$bf->is_maintainer_modified('DPKGFLAGS'), 'strip marked flag as non-maint modified'); | |
39 | ||
40 | $bf->append('DPKGFLAGS', '-Wl,other', 'vendor', 0); | |
41 | is($bf->get('DPKGFLAGS'), '-Wflag -fsome -Wl,other', 'get appended flag'); | |
42 | is($bf->get_origin('DPKGFLAGS'), 'vendor', 'flag has a vendor origin'); | |
43 | ok(!$bf->is_maintainer_modified('DPKGFLAGS'), 'append marked flag as non-maint modified'); | |
44 | ||
45 | $bf->prepend('DPKGFLAGS', '-Idir', 'env', 1); | |
46 | is($bf->get('DPKGFLAGS'), '-Idir -Wflag -fsome -Wl,other', 'get prepended flag'); | |
47 | is($bf->get_origin('DPKGFLAGS'), 'env', 'flag has an env origin'); | |
48 | ok($bf->is_maintainer_modified('DPKGFLAGS'), 'prepend marked flag as maint modified'); | |
49 | ||
50 | # TODO: Add more test cases. | |
51 | ||
52 | 1; |