aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/component/deb/test_buildpackage.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/component/deb/test_buildpackage.py')
-rw-r--r--tests/component/deb/test_buildpackage.py59
1 files changed, 29 insertions, 30 deletions
diff --git a/tests/component/deb/test_buildpackage.py b/tests/component/deb/test_buildpackage.py
index 19dfa828..74d1fbb0 100644
--- a/tests/component/deb/test_buildpackage.py
+++ b/tests/component/deb/test_buildpackage.py
@@ -31,42 +31,32 @@ from gbp.scripts.buildpackage import main as buildpackage
class TestBuildpackage(ComponentTestBase):
"""Test building a debian package"""
- def check_hook_vars(self, name, vars):
- """
- Check that a hook hat the given vars in
- it's environment.
- This assumes the hook was set too
- printenv > hookname.oug
- """
- env = []
- with open('%s.out' % name) as f:
- env = [line.split('=')[0] for line in f.readlines()]
-
- for var in vars:
- ok_(var in env, "%s not found in %s" % (var, env))
-
@staticmethod
def _dsc_name(pkg, version, dir):
return os.path.join(DEB_TEST_DATA_DIR,
dir,
'%s_%s.dsc' % (pkg, version))
- def _test_buildpackage(self, pkg, dir, version):
+ def _test_buildpackage(self, pkg, dir, version, opts=[]):
dsc = self._dsc_name(pkg, version, dir)
assert import_dsc(['arg0', dsc]) == 0
ComponentTestGitRepository(pkg)
+ prebuild_out = os.path.join(os.path.abspath(pkg), 'prebuild.out')
+ postbuild_out = os.path.join(os.path.abspath(pkg), 'postbuild.out')
os.chdir(pkg)
- ret = buildpackage(['arg0',
- '--git-prebuild=printenv > prebuild.out',
- '--git-postbuild=printenv > postbuild.out',
- '--git-builder=/bin/true',
- '--git-cleaner=/bin/true'])
+
+ args = ['arg0',
+ '--git-prebuild=printenv > %s' % prebuild_out,
+ '--git-postbuild=printenv > %s' % postbuild_out,
+ '--git-builder=/bin/true',
+ '--git-cleaner=/bin/true'] + opts
+ ret = buildpackage(args)
ok_(ret == 0, "Building the package failed")
- eq_(os.path.exists('prebuild.out'), True)
+ eq_(os.path.exists(prebuild_out), True)
+ eq_(os.path.exists(postbuild_out), True)
self.check_hook_vars('prebuild', ["GBP_BUILD_DIR",
"GBP_GIT_DIR",
- "GBP_GIT_DIR",
"GBP_BUILD_DIR"])
self.check_hook_vars('postbuild', ["GBP_CHANGES_FILE",
@@ -75,11 +65,11 @@ class TestBuildpackage(ComponentTestBase):
"GBP_BUILD_DIR"])
def test_debian_buildpackage(self):
- """Test that building a native debian package works"""
+ """Test that building a native debian package works"""
self._test_buildpackage('git-buildpackage', 'dsc-native', '0.4.14')
def test_non_native_buildpackage(self):
- """Test that building a native debian package works"""
+ """Test that building a source 3.0 debian package works"""
self._test_buildpackage('hello-debhelper', 'dsc-3.0', '2.8-1')
def test_tag_only(self):
@@ -102,11 +92,11 @@ class TestBuildpackage(ComponentTestBase):
ok_(ret == 0, "Building the package failed")
eq_(os.path.exists('posttag.out'), True)
eq_(os.path.exists('builder-run.stamp'), False)
- self.check_hook_vars('posttag', ["GBP_TAG",
- "GBP_BRANCH",
+ self.check_hook_vars('posttag', [("GBP_TAG", "debian/0.4.14"),
+ ("GBP_BRANCH", "master"),
"GBP_SHA1"])
- def test_subtarball_generation(self):
+ def test_component_generation(self):
"""Test that generating tarball and additional tarball works without pristine-tar"""
pkg = 'hello-debhelper'
dsc = self._dsc_name(pkg, '2.8-1', 'dsc-3.0-additional-tarballs')
@@ -120,7 +110,7 @@ class TestBuildpackage(ComponentTestBase):
for t in tarballs:
self.assertFalse(os.path.exists(t), "Tarball %s must not exist" % t)
ret = buildpackage(['arg0',
- '--git-subtarball=foo',
+ '--git-component=foo',
'--git-no-pristine-tar',
'--git-posttag=printenv > posttag.out',
'--git-builder=touch builder-run.stamp',
@@ -129,7 +119,7 @@ class TestBuildpackage(ComponentTestBase):
for t in tarballs:
self.assertTrue(os.path.exists(t), "Tarball %s not found" % t)
- def test_pristinetar_subtarball_generation(self):
+ def test_pristinetar_component_generation(self):
"""Test that generating tarball and additional tarball works with pristine-tar"""
pkg = 'hello-debhelper'
dsc = self._dsc_name(pkg, '2.8-1', 'dsc-3.0-additional-tarballs')
@@ -143,7 +133,7 @@ class TestBuildpackage(ComponentTestBase):
for t in tarballs:
self.assertFalse(os.path.exists(t), "Tarball %s must not exist" % t)
ret = buildpackage(['arg0',
- '--git-subtarball=foo',
+ '--git-component=foo',
'--git-pristine-tar',
'--git-posttag=printenv > posttag.out',
'--git-builder=touch builder-run.stamp',
@@ -151,3 +141,12 @@ class TestBuildpackage(ComponentTestBase):
ok_(ret == 0, "Building the package failed")
for t in tarballs:
self.assertTrue(os.path.exists(t), "Tarball %s not found" % t)
+
+ def test_export_dir_buildpackage(self):
+ """Test that building with a export dir works"""
+ self._test_buildpackage('hello-debhelper',
+ 'dsc-3.0',
+ '2.8-1',
+ ['--git-export-dir=../foo'],
+ )
+ ok_(os.path.exists('../foo'))