Rev 4464: Cleanup setup tests. in file:///home/vila/src/bzr/bugs/385453-make-pyrex/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Tue Jun 23 13:58:03 BST 2009
At file:///home/vila/src/bzr/bugs/385453-make-pyrex/
------------------------------------------------------------
revno: 4464
revision-id: v.ladeuil+lp at free.fr-20090623125803-vrrrs2n9zsgd4ce1
parent: v.ladeuil+lp at free.fr-20090623065824-tgitxb0v96qa8utd
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 385453-make-pyrex
timestamp: Tue 2009-06-23 14:58:03 +0200
message:
Cleanup setup tests.
* bzrlib/tests/test_setup.py:
(TestSetup): Protect the existing build dir.
(TestSetup.test_build_and_install.rmtree): Use cleanup hooks and
don't clobber the existing build dir.
* .bzrignore:
All pyrex generated files follow the same pattern.
-------------- next part --------------
=== modified file '.bzrignore'
--- a/.bzrignore 2009-06-22 12:52:39 +0000
+++ b/.bzrignore 2009-06-23 12:58:03 +0000
@@ -38,16 +38,8 @@
./api
doc/**/*.html
doc/developers/performance.png
-bzrlib/_bencode_pyx.c
-bzrlib/_btree_serializer_pyx.c
-bzrlib/_chk_map_pyx.c
-bzrlib/_chunks_to_lines_pyx.c
-bzrlib/_dirstate_helpers_pyx.c
-bzrlib/_groupcompress_pyx.c
-bzrlib/_knit_load_data_pyx.c
-bzrlib/_known_graph_pyx.c
-bzrlib/_readdir_pyx.c
-bzrlib/_rio_pyx.c
+# Pyrex generated C files
+bzrlib/_*_pyx.c
bzrlib/_walkdirs_win32.c
doc/en/release-notes/NEWS.txt
doc/en/developer-guide/HACKING.txt
=== modified file 'bzrlib/tests/test_setup.py'
--- a/bzrlib/tests/test_setup.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/test_setup.py 2009-06-23 12:58:03 +0000
@@ -20,22 +20,42 @@
import sys
import subprocess
import shutil
-from tempfile import TemporaryFile
+import tempfile
import bzrlib
-from bzrlib.tests import TestCase, TestSkipped
-import bzrlib.osutils as osutils
+from bzrlib import (
+ osutils,
+ tests,
+ )
-# XXX: This clobbers the build directory in the real source tree; it'd be nice
-# to avoid that.
-#
# TODO: Run bzr from the installed copy to see if it works. Really we need to
# run something that exercises every module, just starting it may not detect
# some missing modules.
#
+# NOTE: Doing the above for every commit seems overkill. I'm not against
+# defining a separate test uite for precisely that purpose to be run at
+# *release* time, but then, our actual test suite sounds adequate
+# -- vila 20090623
+#
# TODO: Check that the version numbers are in sync. (Or avoid this...)
-class TestSetup(TestCase):
+class TestSetup(tests.TestCase):
+
+ def setUp(self):
+ super(TestSetup, self).setUp()
+ # setup.py must be run from the root source directory, but the tests
+ # are not necessarily invoked from there
+ self.source_dir = os.path.dirname(os.path.dirname(bzrlib.__file__))
+ self.build_dir = os.path.join(self.source_dir, 'build')
+ # Do we already have a build dir in the source hierarchy ?
+ if os.path.exists(self.build_dir):
+ # Put it aside during the test
+ tmp_dir = tempfile.mkdtemp(dir=self.source_dir)
+ self.addCleanup(os.rmdir, tmp_dir)
+ tmp_build_dir = os.path.join(tmp_dir, 'build')
+ os.rename(self.build_dir, tmp_build_dir)
+ # And restore it after the test
+ self.addCleanup(os.rename, tmp_build_dir, self.build_dir)
def test_build_and_install(self):
""" test cmd `python setup.py build`
@@ -49,24 +69,29 @@
import distutils.sysconfig
makefile_path = distutils.sysconfig.get_makefile_filename()
if not os.path.exists(makefile_path):
- raise TestSkipped('You must have the python Makefile installed to run this test.'
- ' Usually this can be found by installing "python-dev"')
+ raise TestSkipped('You must have the python Makefile installed'
+ ' to run this test. Usually this can be found'
+ ' by installing "python-dev"')
except ImportError:
- raise TestSkipped('You must have distutils installed to run this test.'
- ' Usually this can be found by installing "python-dev"')
- self.log('test_build running in %s' % os.getcwd())
+ raise TestSkipped('You must have distutils installed to run this'
+ ' test. Usually this can be found by installing'
+ ' "python-dev"')
+ self.log('test_build_and_install running in %s' % os.getcwd())
install_dir = osutils.mkdtemp()
- # setup.py must be run from the root source directory, but the tests
- # are not necessarily invoked from there
- self.source_dir = os.path.dirname(os.path.dirname(bzrlib.__file__))
- try:
- self.run_setup(['clean'])
- # build is implied by install
- ## self.run_setup(['build'])
- self.run_setup(['install', '--prefix', install_dir])
- self.run_setup(['clean'])
- finally:
- osutils.rmtree(install_dir)
+ def rmtree(dir):
+ """Wrap osutils.rmtre
+ osutils.rmtree is lazy loaded and can't be used directly in cleanp
+ hooks
+ """
+ osutils.rmtree(dir)
+ self.addCleanup(rmtree, install_dir)
+ self.addCleanup(rmtree, self.build_dir)
+
+ self.run_setup(['clean'])
+ # build is implied by install
+ ## self.run_setup(['build'])
+ self.run_setup(['install', '--prefix', install_dir])
+ self.run_setup(['clean'])
def run_setup(self, args):
args = [sys.executable, './setup.py', ] + args
More information about the bazaar-commits
mailing list