diff options
author | Guido Günther <agx@sigxcpu.org> | 2016-08-05 08:17:38 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2016-08-05 08:27:59 +0200 |
commit | a8689777e9eae7b07a3cf8a3eae9935825b1fdf3 (patch) | |
tree | 89155ee06baff3e84395850568ba91722ae6b33d | |
parent | 51620e95d11152d3a352b60c45abf86b13464010 (diff) |
tests: match env vars values in hook checks too
-rw-r--r-- | tests/component/__init__.py | 16 | ||||
-rw-r--r-- | tests/component/deb/test_buildpackage.py | 4 | ||||
-rw-r--r-- | tests/component/deb/test_import_orig.py | 10 |
3 files changed, 17 insertions, 13 deletions
diff --git a/tests/component/__init__.py b/tests/component/__init__.py index 79699e2c..6c90bf8e 100644 --- a/tests/component/__init__.py +++ b/tests/component/__init__.py @@ -216,16 +216,22 @@ class ComponentTestBase(unittest.TestCase, GbpLogTester): return h.hexdigest() @staticmethod - def check_hook_vars(name, vars): + def check_hook_vars(name, expected): """ Check that a hook had the given vars in it's environment. This assumes the hook was set too printenv > hookname.out """ - env = [] with open('%s.out' % name) as f: - env = [line.split('=')[0] for line in f.readlines()] + parsed = dict([line[:-1].split('=', 1) for line in f.readlines()]) - for var in vars: - ok_(var in env, "%s not found in %s" % (var, env)) + for var in expected: + if len(var) == 2: + k, v = var + else: + k, v = var, None + ok_(k in parsed, "%s not found in %s" % (k, parsed)) + if v is not None: + ok_(v == parsed[k], + "Got %s not expected value %s for %s" % (parsed[k], v, k)) diff --git a/tests/component/deb/test_buildpackage.py b/tests/component/deb/test_buildpackage.py index 4f80a631..24b1f47f 100644 --- a/tests/component/deb/test_buildpackage.py +++ b/tests/component/deb/test_buildpackage.py @@ -87,8 +87,8 @@ 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_component_generation(self): diff --git a/tests/component/deb/test_import_orig.py b/tests/component/deb/test_import_orig.py index cb68e3e0..c4e1bad6 100644 --- a/tests/component/deb/test_import_orig.py +++ b/tests/component/deb/test_import_orig.py @@ -83,12 +83,10 @@ class TestImportOrig(ComponentTestBase): self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'], tags=['debian/2.6-2', 'upstream/2.6', 'upstream/2.8']) eq_(os.path.exists('postimport.out'), True) - self.check_hook_vars('postimport', ["GBP_BRANCH", - "GBP_TAG", - "GBP_UPSTREAM_VERSION", - "GBP_DEBIAN_VERSION"]) - - + self.check_hook_vars('postimport', [("GBP_BRANCH", "master"), + ("GBP_TAG", "upstream/2.8"), + ("GBP_UPSTREAM_VERSION", "2.8"), + ("GBP_DEBIAN_VERSION", "2.8-1")]) def test_update_component_tarballs(self): """ |