1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
# test_builder.py -- Testsuite for builddeb builder.py
# Copyright (C) 2007 James Westby <jw+debian@jameswestby.net>
#
# This file is part of bzr-builddeb.
#
# bzr-builddeb is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# bzr-builddeb is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with bzr-builddeb; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
import os
from ....tests import TestCaseInTempDir
from ..builder import (
DebBuild,
BuildFailedError,
NoSourceDirError,
)
class TestDebBuild(TestCaseInTempDir):
def test_prepare_makes_parents(self):
builder = DebBuild(None, 'target/sub/sub2', None)
builder.prepare()
self.assertPathExists('target/sub')
self.assertPathDoesNotExist('target/sub/sub2')
def test_prepare_purges_dir(self):
self.build_tree(['target/', 'target/sub/'])
builder = DebBuild(None, 'target/sub/', None)
builder.prepare()
self.assertPathExists('target')
self.assertPathDoesNotExist('target/sub')
def test_use_existing_preserves(self):
self.build_tree(['target/', 'target/sub/'])
builder = DebBuild(None, 'target/sub/', None, use_existing=True)
builder.prepare()
self.assertPathExists('target/sub')
def test_use_existing_errors_if_not_present(self):
self.build_tree(['target/'])
builder = DebBuild(None, 'target/sub/', None, use_existing=True)
self.assertRaises(NoSourceDirError, builder.prepare)
self.assertPathDoesNotExist('target/sub')
def test_export(self):
class MkdirDistiller:
def distill(self, target):
os.mkdir(target)
builder = DebBuild(MkdirDistiller(), 'target', None)
builder.export()
self.assertPathExists('target')
def test_build(self):
builder = DebBuild(None, 'target', "touch built")
self.build_tree(['target/'])
builder.build()
self.assertPathExists('target/built')
def test_build_fails(self):
builder = DebBuild(None, 'target', "false")
self.build_tree(['target/'])
self.assertRaises(BuildFailedError, builder.build)
def test_clean(self):
builder = DebBuild(None, 'target', None)
self.build_tree(['target/', 'target/foo'])
builder.clean()
self.assertPathDoesNotExist('target')
|