[Reproducible-commits] [dpkg] 84/105: Dpkg::Build::Types: Allow disabling the checks in set_build_type()

Niko Tyni ntyni at moszumanska.debian.org
Mon May 2 13:49:56 UTC 2016


This is an automated email from the git hooks/post-receive script.

ntyni pushed a commit to branch ntyni/reproducible_builds
in repository dpkg.

commit e731c1fcca81470e08f81ded165243bc5f05f8d0
Author: Guillem Jover <guillem at debian.org>
Date:   Sun May 1 17:20:16 2016 +0200

    Dpkg::Build::Types: Allow disabling the checks in set_build_type()
    
    This makes it possible to test the different code paths.
---
 scripts/Dpkg/Build/Types.pm  | 10 +++++++---
 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 9f19c77..7f6f1bc 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 0fdfbed..d237c03 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;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list