build: Add support for compiler analyzer flags
[dpkg.git] / scripts / t / Dpkg_BuildTypes.t
blob639d8b23b67f1faf958b877d5fa3ee73e1e4199b
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 => 39;
21 BEGIN {
22 use_ok('Dpkg::BuildTypes');
25 ok(build_is(BUILD_DEFAULT | BUILD_FULL), 'build is default full');
26 is(get_build_options_from_type(), 'full', 'build is full');
28 set_build_type(BUILD_DEFAULT | BUILD_BINARY, '--default-binary');
29 is(get_build_options_from_type(), 'binary', 'build is binary');
30 ok(build_is(BUILD_DEFAULT | BUILD_BINARY), 'build is default binary');
32 set_build_type(BUILD_SOURCE | BUILD_ARCH_INDEP, '--build=source,all');
33 is(get_build_options_from_type(), 'source,all', 'build is source,all');
35 set_build_type_from_options('any,all', '--build=any,all', nocheck => 1);
36 is(get_build_options_from_type(), 'binary', 'build is binary from any,all');
37 ok(build_is(BUILD_BINARY), 'build is any,all');
39 set_build_type_from_options('binary', '--build=binary', nocheck => 1);
40 is(get_build_options_from_type(), 'binary', 'build is binary');
41 ok(build_is(BUILD_BINARY), 'build is binary');
43 set_build_type_from_options('source,all', '--build=source,all', nocheck => 1);
44 ok(build_is(BUILD_SOURCE | BUILD_ARCH_INDEP), 'build source,all is source,all');
45 ok(!build_is(BUILD_SOURCE | BUILD_ARCH_DEP), 'build source,all is not source,any');
46 ok(build_has_any(BUILD_SOURCE), 'build source,all has_any source');
47 ok(build_has_any(BUILD_ARCH_INDEP), 'build source,all has_any any');
48 ok(build_has_none(BUILD_DEFAULT), 'build source,all has_none default');
49 ok(build_has_none(BUILD_ARCH_DEP), 'build source,all has_none any');
50 ok(!build_has_all(BUILD_BINARY), 'build source,all not has_all binary');
51 ok(!build_has_all(BUILD_SOURCE | BUILD_ARCH_DEP),
52 'build source,all not has_all source,any');
53 ok(!build_has_all(BUILD_FULL), 'build source,all has_all full');
55 set_build_type_from_targets('build-arch,build-indep',
56 '--targets=build-arch,build-indep', nocheck => 1);
57 is(get_build_options_from_type(), 'binary',
58 'build is binary from build-arch,build-indep');
59 ok(build_is(BUILD_BINARY), 'build is binary from build-arch,build-indep');
61 set_build_type_from_targets('binary', '--targets=binary', nocheck => 1);
62 is(get_build_options_from_type(), 'binary', 'build is binary from binary');
63 ok(build_is(BUILD_BINARY), 'build is binary from binary');
65 set_build_type_from_targets('clean,binary-indep',
66 '--targets=clean,binary-indep', nocheck => 1);
67 ok(build_is(BUILD_SOURCE | BUILD_ARCH_INDEP), 'build source,all is source,all');
68 ok(!build_is(BUILD_SOURCE | BUILD_ARCH_DEP), 'build source,all is not source,any');
69 ok(build_has_any(BUILD_SOURCE), 'build source,all has_any source');
70 ok(build_has_any(BUILD_ARCH_INDEP), 'build source,all has_any any');
71 ok(build_has_none(BUILD_DEFAULT), 'build source,all has_none default');
72 ok(build_has_none(BUILD_ARCH_DEP), 'build source,all has_none any');
73 ok(!build_has_all(BUILD_BINARY), 'build source,all not has_all binary');
74 ok(!build_has_all(BUILD_SOURCE | BUILD_ARCH_DEP),
75 'build source,all not has_all source,any');
76 ok(!build_has_all(BUILD_FULL), 'build source,all has_all full');
78 set_build_type(BUILD_BINARY, '--build=binary', nocheck => 1);
79 ok(build_is(BUILD_BINARY), 'build binary is binary');
80 ok(build_has_any(BUILD_ARCH_DEP), 'build binary has_any any');
81 ok(build_has_any(BUILD_ARCH_INDEP), 'build binary has_any all');
82 ok(build_has_all(BUILD_BINARY), 'build binary has_all binary');
83 ok(build_has_none(BUILD_SOURCE), 'build binary has_none source');
85 set_build_type(BUILD_FULL, '--build=full', nocheck => 1);
86 ok(build_has_any(BUILD_SOURCE), 'build full has_any source');
87 ok(build_has_all(BUILD_BINARY), 'build full has_all binary');