[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[lintian] 02/02: t/runtests: Use a whitelist to clean the environment



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

nthykier pushed a commit to branch master
in repository lintian.

commit 736f037f7f919cc5d7473d7d6bb649cf1d8d04b5
Author: Niels Thykier <niels@thykier.net>
Date:   Sat Jan 23 08:26:41 2016 +0000

    t/runtests: Use a whitelist to clean the environment
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 debian/changelog |  4 ++++
 t/runtests       | 27 +++++++++++++++++++--------
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index e396455..2faddd4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,10 @@ lintian (2.5.41) UNRELEASED; urgency=medium
   * debian/rules:
     + [NT] Only run tests from the override_dh_auto_test target.
 
+  * t/runtests:
+    + [NT] Use a whitelist for cleaning up the environment.  Fixes
+      FTBFS / test failures.
+
  -- Niels Thykier <niels@thykier.net>  Fri, 22 Jan 2016 21:48:04 +0000
 
 lintian (2.5.40) unstable; urgency=medium
diff --git a/t/runtests b/t/runtests
index de210d0..8ec5f05 100755
--- a/t/runtests
+++ b/t/runtests
@@ -44,6 +44,25 @@ use constant SUITES => qw(scripts changes debs source tests);
 our ($LINTIAN_ROOT, $LINTIAN, @LINTIAN_CMD);
 
 BEGIN {
+    # Whitelist the part of the environment we permit.  This is to
+    # avoid inheriting things that messes up tests (like CFLAGS,
+    # DH_OPTIONS, DEB_HOST_ARCH etc.)
+    my %PRESERVE_ENV = map { $_ => 1 } qw(
+      LINTIAN_TEST_INSTALLED
+      NO_PKG_MANGLE
+      PATH
+      TMPDIR
+    );
+    # TODO: MAKEFLAGS - some of the tests don't cope too well with it
+    for my $key (keys(%ENV)) {
+        delete $ENV{$key}
+          if not exists($PRESERVE_ENV{$key});
+
+    }
+    for my $var (sort(keys(%ENV))) {
+        print "ENV[$var]=$ENV{$var}\n";
+    }
+
     if (($ENV{'LINTIAN_TEST_INSTALLED'}//'no') eq 'yes') {
         $LINTIAN_ROOT = '/usr/share/lintian';
         $LINTIAN = '/usr/bin/lintian';
@@ -55,14 +74,6 @@ BEGIN {
     $ENV{'LINTIAN_FRONTEND'} = $LINTIAN;
     @LINTIAN_CMD = ($LINTIAN);
 
-    delete $ENV{'LINTIAN_CFG'};
-    delete $ENV{'LINTIAN_LAB'};
-    delete($ENV{'LINTIAN_PROFILE'});
-    delete($ENV{'LINTIAN_COVERAGE'});
-    # Some of the tests don't cope too well with "-j" in MAKEFLAGS
-    delete($ENV{'MAKEFLAGS'});
-    # Ensure Lintian works without $ENV{HOME}
-    delete($ENV{'HOME'});
     # Ubuntu auto-builders run pkg-mangle which messes with our
     # test packages, so ask it not to do so by default.
     $ENV{'NO_PKG_MANGLE'} = 'true'

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


Reply to: