~bzr-pqm/bzr/bzr.dev

1692.7.6 by Martin Pool
[patch] force deletion of trees containing readonly files (alexander)
1
# Copyright (C) 2005, 2006 by Canonical Ltd
2
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
1185.33.89 by Martin Pool
[patch] add a selftest test that the setup build script works (Alexander Belchenko)
17
""" test for setup.py build process """
18
19
import os
1185.31.59 by John Arbash Meinel
Switch to sys.executable instead of just 'python' to make sure to run the right executable
20
import sys
21
import subprocess
1185.33.89 by Martin Pool
[patch] add a selftest test that the setup build script works (Alexander Belchenko)
22
import shutil
1540.3.32 by Martin Pool
Clean up test_setup code; avoid possible pipe jam
23
from tempfile import TemporaryFile
1185.33.89 by Martin Pool
[patch] add a selftest test that the setup build script works (Alexander Belchenko)
24
25
from bzrlib.tests import TestCase
1692.7.6 by Martin Pool
[patch] force deletion of trees containing readonly files (alexander)
26
import bzrlib.osutils as osutils
1185.33.89 by Martin Pool
[patch] add a selftest test that the setup build script works (Alexander Belchenko)
27
1540.3.31 by Martin Pool
Fix up TestSetup.tearDown - shouldn't try to remove nonexistent directory
28
# TODO: ideally run this in a separate directory, so as not to clobber the
29
# real build directory
30
1185.33.89 by Martin Pool
[patch] add a selftest test that the setup build script works (Alexander Belchenko)
31
class TestSetup(TestCase):
32
33
    def test_build(self):
1540.3.31 by Martin Pool
Fix up TestSetup.tearDown - shouldn't try to remove nonexistent directory
34
        """ test cmd `python setup.py build`
1821.1.1 by Alexander Belchenko
win32 installer for bzr.dev.0.9
35
36
        This test ensure that build process run correct.
37
        Ensure that man generator works correct.
38
        Also can catches new subdirectories which weren't added to setup.py
1540.3.31 by Martin Pool
Fix up TestSetup.tearDown - shouldn't try to remove nonexistent directory
39
        """
1540.3.32 by Martin Pool
Clean up test_setup code; avoid possible pipe jam
40
        self.log('test_build running in %s' % os.getcwd())
41
        try:
42
            # run setup.py build as subproces and catch return code
43
            out_file = TemporaryFile()
44
            err_file = TemporaryFile()
45
            p = subprocess.Popen([sys.executable, 'setup.py', 'build'],
46
                                 stdout=out_file, stderr=err_file)
47
            s = p.communicate()
48
            self.assertEqual(0, p.returncode, '`python setup.py build` fails')
49
        finally:
50
            if os.path.exists('build'):
1692.7.6 by Martin Pool
[patch] force deletion of trees containing readonly files (alexander)
51
                osutils.rmtree(u'build')