...
 
Commits (7)
......@@ -2,3 +2,4 @@ dist
*.pyc
*.egg-info
.tox
*.egg
......@@ -33,6 +33,12 @@ Supported options
and if the values do not match the execution of the recipe will
fail.
``cleanup``
List of files / directories, separated by blanks, that will be removed
at the end of the build. This feature supports wildcards.
Basically, it's used to clean things like sources or documentation
``make-binary``
Path to the ``make`` program. Defaults to 'make' which
......@@ -1079,3 +1085,4 @@ Contributors
* Guy Rozendorn (grzn)
* Marco Mariani (mmariani)
* galpin
* Thomas Larrieu (thomas.larrieu)
This diff is collapsed.
......@@ -7,6 +7,7 @@ import shutil
import stat
import tarfile
import tempfile
import glob
from time import sleep
import zc.buildout
import zc.buildout.testing
......@@ -292,7 +293,7 @@ class NonInformativeTests(unittest.TestCase):
recipe.buildout_prefix = prefix
file_list = recipe.get_installed_files(ref_path)
installed_files.pop(2)
self.assertEquals([os.path.relpath(f, prefix) for f in file_list], installed_files)
self.assertItemsEqual([os.path.relpath(f, prefix) for f in file_list], installed_files)
def test_honor_buidlout_keep_compile_directory(self):
buildout = {'keep-compile-dir' : 'true'}
......@@ -307,6 +308,89 @@ class NonInformativeTests(unittest.TestCase):
build_directory = os.path.join(self.dir, 'test_parts/test__compile__')
self.assertTrue(os.path.exists(build_directory))
def test_cleanup(self):
recipe = self.make_recipe(
{},
'test',
{
'url': 'file://%s/testdata/package-0.0.0.tar.gz' % os.path.dirname(__file__),
'cleanup': 'foo\nbar'
}
)
os.mkdir(recipe.options.get('prefix'))
os.chdir(recipe.options.get('prefix'))
tmp = open('foo', 'a')
tmp = open('bar', 'a')
self.assertTrue(os.path.exists('foo'))
self.assertTrue(os.path.exists('bar'))
recipe.install()
self.assertFalse(os.path.exists('foo'))
self.assertFalse(os.path.exists('bar'))
def test_cleanup_succeeds_when_glob_is_valid(self):
recipe = self.make_recipe(
{},
'test',
{
'url': 'file://%s/testdata/package-0.0.0.tar.gz' % os.path.dirname(__file__),
'cleanup': 'foo/*'
}
)
os.mkdir(recipe.options.get('prefix'))
os.chdir(recipe.options.get('prefix'))
os.mkdir('foo')
tmp = open('foo/bar', 'a')
tmp = open('foo/barz', 'a')
self.assertTrue(os.path.exists('foo/bar'))
self.assertTrue(os.path.exists('foo/barz'))
recipe.install()
self.assertFalse(os.path.exists('foo/bar'))
self.assertFalse(os.path.exists('foo/barz'))
def test_cleanup_fails_when_file_does_not_exist(self):
os.chdir(self.dir)
recipe = self.make_recipe(
{},
'test',
{
'url': 'file://%s/testdata/package-0.0.0.tar.gz' % os.path.dirname(__file__),
'cleanup': 'foo'
}
)
self.assertFalse(os.path.exists(os.path.join(self.dir, 'foo')))
with self.assertRaises(IOError):
recipe.install()
def test_cleanup_fails_when_file_is_out_of_reach(self):
os.chdir(self.dir)
recipe = self.make_recipe(
{},
'test',
{
'url': 'file://%s/testdata/package-0.0.0.tar.gz' % os.path.dirname(__file__),
'cleanup': '/tmp/foo'
}
)
open('/tmp/foo', 'a')
self.assertTrue(os.path.exists('/tmp/foo'))
with self.assertRaises(IOError):
recipe.install()
def test_cleanup_fails_when_unmatched_glob(self):
os.chdir(self.dir)
pattern = '/tmp/foo/trololol*'
recipe = self.make_recipe({}, 'test',
{
'url': 'file://%s/testdata/package-0.0.0.tar.gz' % os.path.dirname(__file__),
'cleanup': pattern
}
)
self.assertEqual(glob.glob(pattern), [])
with self.assertRaises(IOError):
recipe.install()
def test_suite():
suite = unittest.TestSuite((
doctest.DocFileSuite(
......