Rev 5949: (jameinel) Don't use real $HOME in test_import_tariffs (while still in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Jun 1 10:47:16 UTC 2011


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5949 [merge]
revision-id: pqm at pqm.ubuntu.com-20110601104714-d421mcfal6nx8sz0
parent: pqm at pqm.ubuntu.com-20110601100041-xxi0zwzza9z4oz64
parent: andrew.bennetts at canonical.com-20110601061418-vq6xqegy6250vxrp
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2011-06-01 10:47:14 +0000
message:
  (jameinel) Don't use real $HOME in test_import_tariffs (while still
   exercising plugins). (Andrew Bennetts)
modified:
  bzrlib/tests/test_import_tariff.py test_import_tariff.p-20100207155145-ff9infp7goncs7zh-1
  doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
=== modified file 'bzrlib/tests/test_import_tariff.py'
--- a/bzrlib/tests/test_import_tariff.py	2011-05-30 07:36:53 +0000
+++ b/bzrlib/tests/test_import_tariff.py	2011-05-31 06:15:24 +0000
@@ -18,10 +18,11 @@
 """Tests for how many modules are loaded in executing various commands."""
 
 import os
+
 from testtools import content
 
 from bzrlib import (
-    osutils,
+    plugins as _mod_plugins,
     trace,
     )
 from bzrlib.bzrdir import BzrDir
@@ -67,22 +68,10 @@
     """
 
     def setUp(self):
-        # Preserve some env vars as we want to escape the isolation for them
         self.preserved_env_vars = {}
-        for name in ('BZR_HOME', 'BZR_PLUGIN_PATH', 'BZR_DISABLE_PLUGINS',
-                     'BZR_PLUGINS_AT', 'HOME'):
+        for name in ('BZR_DISABLE_PLUGINS', 'BZR_PLUGINS_AT'):
             self.preserved_env_vars[name] = os.environ.get(name)
         super(TestImportTariffs, self).setUp()
-        # We don't want to pollute the user's .bzr.log so we define our own.
-        self.log_path = osutils.pathjoin(self.test_home_dir, '.bzr.log')
-        self.overrideEnv('BZR_LOG', self.log_path)
-
-    def test_log_path_overriden(self):
-        # ensure we get the log file in the right place
-        actual_log_path = trace._get_bzr_log_filename()
-        self.assertStartsWith(actual_log_path, self.test_home_dir)
-        self.assertEquals(self.log_path, actual_log_path)
-
 
     def start_bzr_subprocess_with_import_check(self, args, stderr_file=None):
         """Run a bzr process and capture the imports.
@@ -90,17 +79,19 @@
         This is fairly expensive because we start a subprocess, so we aim to
         cover representative rather than exhaustive cases.
         """
-        # We use PYTHON_VERBOSE rather than --profile-importts because in
+        # We use PYTHON_VERBOSE rather than --profile-imports because in
         # experimentation the profile-imports output seems to not always show
         # the modules you'd expect; this can be debugged but python -v seems
         # more likely to always show everything.  And we use the environment
         # variable rather than 'python -v' in the hope it will work even if
         # bzr is frozen and python is not explicitly specified. -- mbp 20100208
-
-        # Normally we want test isolation from the real $HOME but here we
-        # explicitly do want to test against things installed there, therefore
-        # we pass it through.
-        env_changes = dict(PYTHONVERBOSE='1', **self.preserved_env_vars)
+        # We use BZR_PLUGIN_PATH to explicitly set the subprocess to use the
+        # same plugins as this process.
+        plugin_path = os.pathsep.join(
+            ['-core', '-site'] + _mod_plugins.__path__)
+        env_changes = dict(PYTHONVERBOSE='1', BZR_PLUGIN_PATH=plugin_path)
+        env_changes.update(self.preserved_env_vars)
+        trace.mutter('Setting env for bzr subprocess: %r', env_changes)
         kwargs = dict(env_changes=env_changes,
                       allow_plugins=(not are_plugins_disabled()))
         if stderr_file:

=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt	2011-06-01 10:00:41 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt	2011-06-01 10:47:14 +0000
@@ -93,9 +93,6 @@
    suite.  This can include new facilities for writing tests, fixes to 
    spurious test failures and changes to the way things should be tested.
 
-* Don't use ``$HOME/.bzr.log`` for the TestImportTariffs tests.
-  (Vincent Ladeuil, #789505)
-
 * Fix deadlock in `TestImportTariffs.test_simple_serve` when stderr gets
   more output than fits in the default buffer.  This was happening on the
   Windows buildslave, and could easily happen in other circumstances where
@@ -105,17 +102,23 @@
 * Fix spurious test failure on OSX for WorkingTreeFormat2.
   (Vincent Ladeuil, #787942)
 
+* Show log file contents from subprocesses started by
+  `start_bzr_subprocess` in test failure details.  This may help diagnose
+  strange hangs and failures involving subprocesses.  (Andrew Bennetts)
+
 * Skip ``utextwrap`` tests when ``sphinx`` breaks text_wrap by an hostile
   monkeypatch to textwrap.TextWrapper.wordsep_re.
   (Vincent Ladeuil, #785098)
 
-* Show log file contents from subprocesses started by
-  `start_bzr_subprocess` in test failure details.  This may help diagnose
-  strange hangs and failures involving subprocesses.  (Andrew Bennetts)
-
 * Multiple ``selftest --exclude`` options are now combined instead of
   overriding each other. (Vincent Ladeuil, #746991)
 
+* `TestImportTariffs` no longer uses the real ``$HOME``.  This prevents it
+  from polluting ``$HOME/.bzr.log`` or being accidentally influenced by
+  user configuration such as aliases.  It still runs with all the user's
+  plugins enabled, as intended.
+  (Vincent Ladeuil, Andrew Bennetts, #789505)
+
 
 bzr 2.4b3
 #########




More information about the bazaar-commits mailing list