← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~frankban/launchpad-buildd/env-cleanup into lp:launchpad-buildd

 

Francesco Banconi has proposed merging lp:~frankban/launchpad-buildd/env-cleanup into lp:launchpad-buildd.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~frankban/launchpad-buildd/env-cleanup/+merge/108901

This branch changes the way env vars are set up in the `BuilddSlaveTestSetup` fixture: `fixtures.EnvironmentVariable` is used so that previous values are restored during clean up.
We need this to fix bugs like bug 1007579: this is an isolation/ordering issue, and can be reproduced in this way:

- create a file containing these two tests:

lp.buildmaster.tests.test_builder.TestSlaveWithLibrarian.test_ensurepresent_librarian
lp.codehosting.tests.test_acceptance.AcceptanceTests.test_branch_renaming(sftp)

- run bin/test -cvv --load-list mytests

The first test uses `BuilddSlaveTestSetup`, the second one fails trying to open the bzr log file in '/var/tmp/buildd/.bzr.log' (because now $HOME is'/var/tmp/buildd/').

-- 
https://code.launchpad.net/~frankban/launchpad-buildd/env-cleanup/+merge/108901
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~frankban/launchpad-buildd/env-cleanup into lp:launchpad-buildd.
=== modified file 'lpbuildd/tests/harness.py'
--- lpbuildd/tests/harness.py	2011-11-21 06:07:33 +0000
+++ lpbuildd/tests/harness.py	2012-06-06 09:05:33 +0000
@@ -12,6 +12,7 @@
 import unittest
 from ConfigParser import SafeConfigParser
 
+from fixtures import EnvironmentVariable
 from txfixtures.tachandler import TacTestFixture
 
 from lpbuildd.slave import BuildDSlave
@@ -102,8 +103,9 @@
         os.mkdir(self.root)
         filecache = os.path.join(self.root, 'filecache')
         os.mkdir(filecache)
-        os.environ['HOME'] = self.root
-        os.environ['BUILDD_SLAVE_CONFIG'] = test_conffile
+        self.useFixture(EnvironmentVariable('HOME', self.root))
+        self.useFixture(
+            EnvironmentVariable('BUILDD_SLAVE_CONFIG', test_conffile))
         # XXX cprov 2005-05-30:
         # When we are about running it seriously we need :
         # * install sbuild package


Follow ups