summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbst-marge-bot <marge-bot@buildstream.build>2019-07-18 10:44:51 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2019-07-18 10:44:51 +0000
commitd79747d7ee2596a73f4ec68bd40bd2ca04427a93 (patch)
tree496c631a82fc7fd488a47747e31ebba3fb4ce202
parentef4cc3f2ff5c134d5fce500398158be2a7baf81a (diff)
parent490fed1cfc712a3aeee3ad3cdc9520edbfa1675c (diff)
downloadbuildstream-d79747d7ee2596a73f4ec68bd40bd2ca04427a93.tar.gz
Merge branch 'traveltissues/fix-update-script' into 'master'
Mock BST_TEST_SUITE env when running update.py Closes #1074 See merge request BuildStream/buildstream!1468
-rwxr-xr-xtests/cachekey/update.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/cachekey/update.py b/tests/cachekey/update.py
index 68016ed6a..feda5dbde 100755
--- a/tests/cachekey/update.py
+++ b/tests/cachekey/update.py
@@ -13,6 +13,7 @@
#
import os
import tempfile
+from unittest import mock
from buildstream.testing.runcli import Cli
# This weird try / except is needed, because this will be imported differently
@@ -41,7 +42,7 @@ def update_keys():
with tempfile.TemporaryDirectory(dir=PROJECT_DIR) as tmpdir:
directory = os.path.join(tmpdir, 'cache')
os.makedirs(directory)
- cli = Cli(directory, verbose=False)
+ cli = Cli(directory, verbose=True)
# Run bst show
result = cli.run(project=PROJECT_DIR, silent=True, args=[
@@ -51,6 +52,9 @@ def update_keys():
])
# Load the actual keys, and the expected ones if they exist
+ if not result.output:
+ print("No results from parsing {}:target.bst".format(PROJECT_DIR))
+ return
actual_keys = parse_output_keys(result.output)
expected_keys = load_expected_keys(PROJECT_DIR, actual_keys, raise_error=False)
@@ -67,4 +71,9 @@ def update_keys():
if __name__ == '__main__':
- update_keys()
+ # patch the environment BST_TEST_SUITE value to something if it's not
+ # present. This avoids an exception thrown at the cli level
+ bst = 'BST_TEST_SUITE'
+ mock_bst = os.environ.get(bst, 'True')
+ with mock.patch.dict(os.environ, {**os.environ, bst: mock_bst}):
+ update_keys()