dpkg (1.18.25) stretch; urgency=medium
[dpkg] / scripts / t / Dpkg_Build_Types.t
CommitLineData
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
16use strict;
17use warnings;
18
19use Test::More tests => 26;
20
21BEGIN {
22 use_ok('Dpkg::Build::Types');
23}
24
25ok(build_is(BUILD_DEFAULT | BUILD_FULL), 'build is default full');
26is(get_build_options_from_type(), 'full', 'build is full');
27
28set_build_type(BUILD_DEFAULT | BUILD_BINARY, '--default-binary');
29is(get_build_options_from_type(), 'binary', 'build is binary');
30ok(build_is(BUILD_DEFAULT | BUILD_BINARY), 'build is default binary');
31
32set_build_type(BUILD_SOURCE | BUILD_ARCH_INDEP, '--build=source,all');
33is(get_build_options_from_type(), 'source,all', 'build is source,all');
34
35set_build_type_from_options('any,all', '--build=any,all', nocheck => 1);
36is(get_build_options_from_type(), 'binary', 'build is binary from any,all');
37ok(build_is(BUILD_BINARY), 'build is any,all');
38
39set_build_type_from_options('binary', '--build=binary', nocheck => 1);
40is(get_build_options_from_type(), 'binary', 'build is binary');
41ok(build_is(BUILD_BINARY), 'build is binary');
42
43set_build_type_from_options('source,all', '--build=source,all', nocheck => 1);
44ok(build_is(BUILD_SOURCE | BUILD_ARCH_INDEP), 'build source,all is source,all');
45ok(!build_is(BUILD_SOURCE | BUILD_ARCH_DEP), 'build source,all is not source,any');
46ok(build_has_any(BUILD_SOURCE), 'build source,all has_any source');
47ok(build_has_any(BUILD_ARCH_INDEP), 'build source,all has_any any');
48ok(build_has_none(BUILD_DEFAULT), 'build source,all has_none default');
49ok(build_has_none(BUILD_ARCH_DEP), 'build source,all has_none any');
50ok(!build_has_all(BUILD_BINARY), 'build source,all not has_all binary');
51ok(!build_has_all(BUILD_SOURCE | BUILD_ARCH_DEP),
52 'build source,all not has_all source,any');
53ok(!build_has_all(BUILD_FULL), 'build source,all has_all full');
54
55set_build_type(BUILD_BINARY, '--build=binary', nocheck => 1);
56ok(build_is(BUILD_BINARY), 'build binary is binary');
57ok(build_has_any(BUILD_ARCH_DEP), 'build binary has_any any');
58ok(build_has_any(BUILD_ARCH_INDEP), 'build binary has_any all');
59ok(build_has_all(BUILD_BINARY), 'build binary has_all binary');
60ok(build_has_none(BUILD_SOURCE), 'build binary has_none source');
61
62set_build_type(BUILD_FULL, '--build=full', nocheck => 1);
63ok(build_has_any(BUILD_SOURCE), 'build full has_any source');
64ok(build_has_all(BUILD_BINARY), 'build full has_all binary');
65
661;