aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/component/deb/test_buildpackage.py
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2015-12-30 19:41:22 +0100
committerGuido Günther <agx@sigxcpu.org>2016-01-15 18:10:40 +0100
commit9cc0a3fe8f6fd0cb70cccabef971ec104e162742 (patch)
treed97a31d2198101a7f300c0bd5a9bbb980b86bacd /tests/component/deb/test_buildpackage.py
parent6aba6357808d9f1e2336dce9fb06372166f843ed (diff)
buildpackage: Move git-pbuilder environemt variables into GBP_ namespace
Keep the old ones for backward compatibility but this way they're all available to all hooks and not only to prebuild. In order to not put more stuff into the process enviroment dont use os.environ but only pass these in via extra_env. While at that test that hooks actually get their environment variables set up correctly.
Diffstat (limited to 'tests/component/deb/test_buildpackage.py')
-rw-r--r--tests/component/deb/test_buildpackage.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/component/deb/test_buildpackage.py b/tests/component/deb/test_buildpackage.py
index 4204f643..020b79fd 100644
--- a/tests/component/deb/test_buildpackage.py
+++ b/tests/component/deb/test_buildpackage.py
@@ -22,7 +22,7 @@ from tests.component import (ComponentTestBase,
ComponentTestGitRepository)
from tests.component.deb import DEB_TEST_DATA_DIR
-from nose.tools import ok_
+from nose.tools import ok_, eq_
from gbp.scripts.import_dsc import main as import_dsc
from gbp.scripts.buildpackage import main as buildpackage
@@ -31,6 +31,20 @@ 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))
+
def test_debian_buildpackage(self):
"""Test that building a native debian package works"""
def _dsc(version):
@@ -43,6 +57,15 @@ class TestBuildpackage(ComponentTestBase):
repo = ComponentTestGitRepository('git-buildpackage')
os.chdir('git-buildpackage')
ret = buildpackage(['arg0',
+ '--git-prebuild=printenv > prebuild.out',
+ '--git-postbuild=printenv > postbuild.out',
'--git-builder=/bin/true',
'--git-cleaner=/bin/true'])
ok_(ret == 0, "Building the package failed")
+ eq_(os.path.exists('prebuild.out'), True)
+
+ self.check_hook_vars('prebuild', ["GBP_BUILD_DIR",
+ "GBP_GIT_DIR"])
+
+ self.check_hook_vars('postbuild', ["GBP_CHANGES_FILE",
+ "GBP_BUILD_DIR"])