~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_setup.py

  • Committer: Max Bowsher
  • Date: 2012-08-08 11:44:19 UTC
  • mfrom: (6552 +trunk)
  • mto: (6581.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6582.
  • Revision ID: _@maxb.eu-20120808114419-hes7at3ihv3mwi16
MergeĀ lp:bzr

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import subprocess
22
22
 
23
23
import bzrlib
24
 
from bzrlib.tests import TestCase, TestSkipped
25
 
import bzrlib.osutils as osutils
 
24
from bzrlib import tests
26
25
 
27
 
# XXX: This clobbers the build directory in the real source tree; it'd be nice
28
 
# to avoid that.
29
 
#
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.
33
29
#
34
30
# TODO: Check that the version numbers are in sync.  (Or avoid this...)
35
31
 
36
 
class TestSetup(TestCase):
 
32
class TestSetup(tests.TestCaseInTempDir):
37
33
 
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')):
48
 
            raise TestSkipped(
 
44
            self.skip(
49
45
                'There is no setup.py file adjacent to the bzrlib directory')
50
46
        try:
51
47
            import distutils.sysconfig
52
48
            makefile_path = distutils.sysconfig.get_makefile_filename()
53
49
            if not os.path.exists(makefile_path):
54
 
                raise TestSkipped(
 
50
                self.skip(
55
51
                    'You must have the python Makefile installed to run this'
56
52
                    ' test. Usually this can be found by installing'
57
53
                    ' "python-dev"')
58
54
        except ImportError:
59
 
            raise TestSkipped(
 
55
            self.skip(
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()
64
 
        try:
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'])
70
 
        finally:
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")
 
61
        self.run_setup([
 
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])
72
67
 
73
68
    def run_setup(self, args):
74
69
        args = [sys.executable, './setup.py', ] + args