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

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=0e2ae4e706e816a9ce200bb506674d19af25a55f

commit 0e2ae4e706e816a9ce200bb506674d19af25a55f
Author: Guillem Jover <guil...@debian.org>
AuthorDate: Tue Jan 19 04:25:38 2021 +0100

    test: Mock dpkg and gcc for architecture detection code
    
    We should not expect dpkg to be present on the system, which can happen
    during bootstrapping, or on non-dpkg based systems. We should not expect
    gcc to be present on the system, which can happen with the Dpkg perl
    distribution which otherwise does not need a C compiler.
---
 scripts/Makefile.am           |  2 ++
 scripts/t/dpkg_buildpackage.t |  3 +++
 scripts/t/mk.t                |  5 ++++-
 scripts/t/mock-bin/dpkg       | 20 ++++++++++++++++++++
 scripts/t/mock-bin/gcc        | 20 ++++++++++++++++++++
 5 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index f36f0c5c8..0afba01c5 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -380,6 +380,8 @@ test_data = \
        t/mk/vendor-v0.mk \
        t/mk/vendor-v1.mk \
        t/mk/vendor.mk \
+       t/mock-bin/dpkg \
+       t/mock-bin/gcc \
        t/origins/debian \
        t/origins/default \
        t/origins/gnewsense \
diff --git a/scripts/t/dpkg_buildpackage.t b/scripts/t/dpkg_buildpackage.t
index dd4f67a6f..d529eb69c 100644
--- a/scripts/t/dpkg_buildpackage.t
+++ b/scripts/t/dpkg_buildpackage.t
@@ -48,6 +48,9 @@ delete $ENV{SOURCE_DATE_EPOCH};
 # Delete other variables that can affect the tests.
 delete $ENV{$_} foreach grep { m/^DEB_/ } keys %ENV;
 
+# Set architecture variables to not require dpkg nor gcc.
+$ENV{PATH} = "$srcdir/t/mock-bin:$ENV{PATH}";
+
 chdir $tmpdir;
 
 my $tmpl_format = <<'TMPL_FORMAT';
diff --git a/scripts/t/mk.t b/scripts/t/mk.t
index 766aa82e0..269052fa6 100644
--- a/scripts/t/mk.t
+++ b/scripts/t/mk.t
@@ -26,7 +26,7 @@ use Dpkg::ErrorHandling;
 use Dpkg::IPC;
 use Dpkg::Vendor;
 
-my $srcdir = $ENV{srcdir} || '.';
+my $srcdir = rel2abs($ENV{srcdir} || '.');
 my $datadir = test_get_data_path();
 
 # Turn these into absolute names so that we can safely switch to the test
@@ -40,6 +40,9 @@ delete $ENV{MAKEFLAGS};
 # Delete other variables that can affect the tests.
 delete $ENV{$_} foreach grep { m/^DEB_/ } keys %ENV;
 
+# Set architecture variables to not require dpkg nor gcc.
+$ENV{PATH} = "$srcdir/t/mock-bin:$ENV{PATH}";
+
 $ENV{DEB_BUILD_PATH} = rel2abs($datadir);
 
 sub test_makefile {
diff --git a/scripts/t/mock-bin/dpkg b/scripts/t/mock-bin/dpkg
new file mode 100755
index 000000000..fbfba35aa
--- /dev/null
+++ b/scripts/t/mock-bin/dpkg
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+set -e
+
+args="$@"
+
+while [ $# -gt 0 ]; do
+  opt="$1"
+  shift
+
+  case "$opt" in
+  --print-architecture)
+    echo amd64
+    exit 0
+  esac
+done
+
+# Otherwise fail hard.
+echo "$0: unsupported command ($args) in mock wrapper"
+exit 1
diff --git a/scripts/t/mock-bin/gcc b/scripts/t/mock-bin/gcc
new file mode 100755
index 000000000..0174f17bb
--- /dev/null
+++ b/scripts/t/mock-bin/gcc
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+set -e
+
+args="$@"
+
+while [ $# -gt 0 ]; do
+  opt="$1"
+  shift
+
+  case "$opt" in
+  -dumpmachine)
+    echo x86_64-linux-gnu
+    exit 0
+  esac
+done
+
+# Otherwise fail hard.
+echo "$0: unsupported command ($args) in mock wrapper"
+exit 1

-- 
Dpkg.Org's dpkg

Reply via email to