test: Move test_data_file() to test.h
[dpkg.git] / scripts / t / Dpkg_BuildProfiles.t
blob48e1e7edcd0ddffd47c0443429001f2547303dad
1 #!/usr/bin/perl
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/>.
16 use strict;
17 use warnings;
19 use Test::More tests => 8;
21 BEGIN {
22 use_ok('Dpkg::BuildProfiles', qw(parse_build_profiles
23 set_build_profiles
24 get_build_profiles));
27 # TODO: Add actual test cases.
29 my $formula;
31 $formula = [ ];
32 is_deeply([ parse_build_profiles('') ], $formula,
33 'parse build profiles formula empty');
35 $formula = [ [ qw(nocheck) ] ];
36 is_deeply([ parse_build_profiles('<nocheck>') ], $formula,
37 'parse build profiles formula single');
39 $formula = [ [ qw(nocheck nodoc stage1) ] ];
40 is_deeply([ parse_build_profiles('<nocheck nodoc stage1>') ], $formula,
41 'parse build profiles formula AND');
43 $formula = [ [ qw(nocheck) ], [ qw(nodoc) ] ];
44 is_deeply([ parse_build_profiles('<nocheck> <nodoc>') ], $formula,
45 'parse build profiles formula OR');
47 $formula = [ [ qw(nocheck nodoc) ], [ qw(stage1) ] ];
48 is_deeply([ parse_build_profiles('<nocheck nodoc> <stage1>') ], $formula,
49 'parse build profiles formula AND, OR');
52 local $ENV{DEB_BUILD_PROFILES} = 'cross nodoc profile.name';
53 is_deeply([ get_build_profiles() ], [ qw(cross nodoc profile.name) ],
54 'get active build profiles from environment');
57 set_build_profiles(qw(nocheck stage1));
58 is_deeply([ get_build_profiles() ], [ qw(nocheck stage1) ],
59 'get active build profiles explicitly set');