Merge lp:~gz/bzr/run_test_setup_in_tempdir_140874 into lp:bzr/2.5

Proposed by Martin Packman
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 6494
Proposed branch: lp:~gz/bzr/run_test_setup_in_tempdir_140874
Merge into: lp:bzr/2.5
Diff against target: 81 lines (+17/-19)
2 files modified
bzrlib/tests/test_setup.py (+14/-19)
doc/en/release-notes/bzr-2.5.txt (+3/-0)
To merge this branch: bzr merge lp:~gz/bzr/run_test_setup_in_tempdir_140874
Reviewer Review Type Date Requested Status
Vincent Ladeuil Needs Fixing
Review via email: mp+99518@code.launchpad.net

Commit message

Run bt.test_setup in a more isolated environment

Description of the change

The smoketest for setup.py runs with the user's environment and in the current directory, which leads to issues such as the one linked and bug 955314 where running tests makes various build artefacts appear. This branch makes it use a tempdir for both build output and install location.

The downside is this then becomes the test that needs the most space on temp (you can currently get away with just 20MB or so), and I haven't got a neat way of detecting a lack of room and skipping.

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

\o/

57 + self.log('test_build running in %s' % self.source_dir)

running *from* (instead of in) now, no ?

58 + build_dir = os.path.join(self.test_dir, "build")
59 + install_dir = os.path.join(self.test_dir, "install")

That's really nit-picking, but why not osutils.joinpath ?

I won't approve this proposal without a news entry ;-p

review: Needs Fixing
Revision history for this message
Martin Packman (gz) wrote :

> 57 + self.log('test_build running in %s' % self.source_dir)
>
> running *from* (instead of in) now, no ?

Good point, changed.

> 58 + build_dir = os.path.join(self.test_dir, "build")
> 59 + install_dir = os.path.join(self.test_dir, "install")
>
> That's really nit-picking, but why not osutils.joinpath ?

Would't serve any useful purpose, adds some segment checking and forces forward slashes on windows. Being consistent would be an argument for, but only if we had a more unified approach to paths in general.

>
> I won't approve this proposal without a news entry ;-p

Added. :)

Revision history for this message
Martin Packman (gz) wrote :

sent to pqm by email

Revision history for this message
Vincent Ladeuil (vila) wrote :

> Would't serve any useful purpose, adds some segment checking

> and forces forward slashes on windows.

Which shouldn't break right ?

> Being consistent would be an argument for,

Yup, that was mainly my point.

> but
> only if we had a more unified approach to paths in general.

...but using a *single* function to join paths *is* a unification, so using
that as an argument to *not* use osutils seems to aggravate the situation
rather than improving it ;) Not a big deal.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/tests/test_setup.py'
2--- bzrlib/tests/test_setup.py 2011-01-12 01:01:53 +0000
3+++ bzrlib/tests/test_setup.py 2012-03-29 11:31:22 +0000
4@@ -21,19 +21,15 @@
5 import subprocess
6
7 import bzrlib
8-from bzrlib.tests import TestCase, TestSkipped
9-import bzrlib.osutils as osutils
10+from bzrlib import tests
11
12-# XXX: This clobbers the build directory in the real source tree; it'd be nice
13-# to avoid that.
14-#
15 # TODO: Run bzr from the installed copy to see if it works. Really we need to
16 # run something that exercises every module, just starting it may not detect
17 # some missing modules.
18 #
19 # TODO: Check that the version numbers are in sync. (Or avoid this...)
20
21-class TestSetup(TestCase):
22+class TestSetup(tests.TestCaseInTempDir):
23
24 def test_build_and_install(self):
25 """ test cmd `python setup.py build`
26@@ -45,30 +41,29 @@
27 # are not necessarily invoked from there
28 self.source_dir = os.path.dirname(os.path.dirname(bzrlib.__file__))
29 if not os.path.isfile(os.path.join(self.source_dir, 'setup.py')):
30- raise TestSkipped(
31+ self.skip(
32 'There is no setup.py file adjacent to the bzrlib directory')
33 try:
34 import distutils.sysconfig
35 makefile_path = distutils.sysconfig.get_makefile_filename()
36 if not os.path.exists(makefile_path):
37- raise TestSkipped(
38+ self.skip(
39 'You must have the python Makefile installed to run this'
40 ' test. Usually this can be found by installing'
41 ' "python-dev"')
42 except ImportError:
43- raise TestSkipped(
44+ self.skip(
45 'You must have distutils installed to run this test.'
46 ' Usually this can be found by installing "python-dev"')
47- self.log('test_build running in %s' % os.getcwd())
48- root_dir = osutils.mkdtemp()
49- try:
50- self.run_setup(['clean'])
51- # build is implied by install
52- ## self.run_setup(['build'])
53- self.run_setup(['install', '--root', root_dir])
54- self.run_setup(['clean'])
55- finally:
56- osutils.rmtree(root_dir)
57+ self.log('test_build running from %s' % self.source_dir)
58+ build_dir = os.path.join(self.test_dir, "build")
59+ install_dir = os.path.join(self.test_dir, "install")
60+ self.run_setup([
61+ 'build', '-b', build_dir,
62+ 'install', '--root', install_dir])
63+ # Install layout is platform dependant
64+ self.assertPathExists(install_dir)
65+ self.run_setup(['clean', '-b', build_dir])
66
67 def run_setup(self, args):
68 args = [sys.executable, './setup.py', ] + args
69
70=== modified file 'doc/en/release-notes/bzr-2.5.txt'
71--- doc/en/release-notes/bzr-2.5.txt 2012-03-26 17:01:21 +0000
72+++ doc/en/release-notes/bzr-2.5.txt 2012-03-29 11:31:22 +0000
73@@ -73,6 +73,9 @@
74 * Add support for pyftpdlib >= 0.7.0 and drop support for previous pyftpdlib
75 versions. (Vincent Ladeuil, #956027)
76
77+* Run smoketest for setup.py isolated in a tempdir. (Martin Packman, #140874)
78+
79+
80 bzr 2.5.0
81 #########
82

Subscribers

People subscribed via source and target branches