diff options
author | Guillem Jover <guillem@debian.org> | 2016-05-01 17:20:16 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2016-05-02 04:03:19 +0200 |
commit | e731c1fcca81470e08f81ded165243bc5f05f8d0 (patch) | |
tree | dfc98be9428413ade322b2bad3b6f7de5da4043d /scripts | |
parent | 3baee8a7d507d7d24ba9a8762399c54129efc1d7 (diff) | |
download | dpkg-e731c1fcca81470e08f81ded165243bc5f05f8d0.tar.gz |
Dpkg::Build::Types: Allow disabling the checks in set_build_type()
This makes it possible to test the different code paths.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Dpkg/Build/Types.pm | 10 | ||||
-rw-r--r-- | scripts/t/Dpkg_Build_Types.t | 13 |
2 files changed, 19 insertions, 4 deletions
diff --git a/scripts/Dpkg/Build/Types.pm b/scripts/Dpkg/Build/Types.pm index 9f19c77e8..7f6f1bc65 100644 --- a/scripts/Dpkg/Build/Types.pm +++ b/scripts/Dpkg/Build/Types.pm @@ -160,19 +160,23 @@ sub build_is return $current_type == $bits; } -=item set_build_type($build_type, $build_option) +=item set_build_type($build_type, $build_option, %opts) Set the current build type to $build_type, which was specified via the $build_option command-line option. +The function will check and abort on incompatible build type assignments, +this behavior can be disabled by using the boolean option "nocheck". + =cut sub set_build_type { - my ($build_type, $build_option) = @_; + my ($build_type, $build_option, %opts) = @_; usageerr(g_('cannot combine %s and %s'), $current_option, $build_option) - if build_has_none(BUILD_DEFAULT) and $current_type != $build_type; + if not $opts{nocheck} and + build_has_none(BUILD_DEFAULT) and $current_type != $build_type; $current_type = $build_type; $current_option = $build_option; diff --git a/scripts/t/Dpkg_Build_Types.t b/scripts/t/Dpkg_Build_Types.t index 0fdfbedba..d237c03a5 100644 --- a/scripts/t/Dpkg_Build_Types.t +++ b/scripts/t/Dpkg_Build_Types.t @@ -16,7 +16,7 @@ use strict; use warnings; -use Test::More tests => 12; +use Test::More tests => 19; BEGIN { use_ok('Dpkg::Build::Types'); @@ -41,4 +41,15 @@ ok(!build_has_all(BUILD_SOURCE | BUILD_ARCH_DEP), 'build source,all not has_all source,any'); ok(!build_has_all(BUILD_FULL), 'build source,all has_all full'); +set_build_type(BUILD_BINARY, '--build=binary', nocheck => 1); +ok(build_is(BUILD_BINARY), 'build binary is binary'); +ok(build_has_any(BUILD_ARCH_DEP), 'build binary has_any any'); +ok(build_has_any(BUILD_ARCH_INDEP), 'build binary has_any all'); +ok(build_has_all(BUILD_BINARY), 'build binary has_all binary'); +ok(build_has_none(BUILD_SOURCE), 'build binary has_none source'); + +set_build_type(BUILD_FULL, '--build=full', nocheck => 1); +ok(build_has_any(BUILD_SOURCE), 'build full has_any source'); +ok(build_has_all(BUILD_BINARY), 'build full has_all binary'); + 1; |