24
from bzrlib.tests import TestCase, TestSkipped
25
import bzrlib.osutils as osutils
24
from bzrlib import tests
27
# XXX: This clobbers the build directory in the real source tree; it'd be nice
30
26
# TODO: Run bzr from the installed copy to see if it works. Really we need to
31
27
# run something that exercises every module, just starting it may not detect
32
28
# some missing modules.
34
30
# TODO: Check that the version numbers are in sync. (Or avoid this...)
36
class TestSetup(TestCase):
32
class TestSetup(tests.TestCaseInTempDir):
38
34
def test_build_and_install(self):
39
35
""" test cmd `python setup.py build`
45
41
# are not necessarily invoked from there
46
42
self.source_dir = os.path.dirname(os.path.dirname(bzrlib.__file__))
47
43
if not os.path.isfile(os.path.join(self.source_dir, 'setup.py')):
49
45
'There is no setup.py file adjacent to the bzrlib directory')
51
47
import distutils.sysconfig
52
48
makefile_path = distutils.sysconfig.get_makefile_filename()
53
49
if not os.path.exists(makefile_path):
55
51
'You must have the python Makefile installed to run this'
56
52
' test. Usually this can be found by installing'
58
54
except ImportError:
60
56
'You must have distutils installed to run this test.'
61
57
' Usually this can be found by installing "python-dev"')
62
self.log('test_build running in %s' % os.getcwd())
63
root_dir = osutils.mkdtemp()
65
self.run_setup(['clean'])
66
# build is implied by install
67
## self.run_setup(['build'])
68
self.run_setup(['install', '--root', root_dir])
69
self.run_setup(['clean'])
71
osutils.rmtree(root_dir)
58
self.log('test_build running from %s' % self.source_dir)
59
build_dir = os.path.join(self.test_dir, "build")
60
install_dir = os.path.join(self.test_dir, "install")
62
'build', '-b', build_dir,
63
'install', '--root', install_dir])
64
# Install layout is platform dependant
65
self.assertPathExists(install_dir)
66
self.run_setup(['clean', '-b', build_dir])
73
68
def run_setup(self, args):
74
69
args = [sys.executable, './setup.py', ] + args