diff options
author | Benjamin Schubert <contact@benschubert.me> | 2020-05-09 12:24:37 +0100 |
---|---|---|
committer | Benjamin Schubert <contact@benschubert.me> | 2020-05-09 12:24:37 +0100 |
commit | 576e3da33e8b977a33e997d4ce80dc3c17d5da15 (patch) | |
tree | c71f69d572eebb2bdb0d5688a2281395845cbb67 | |
parent | 1fe5189e5fffbd6ca7465a08f3e41c94cd5d5d23 (diff) | |
download | buildstream-bschubert/cache-key-as-source-test.tar.gz |
fixup! cachekey.py: Move source tests for cache keys in sourcetestsbschubert/cache-key-as-source-test
-rw-r--r-- | src/buildstream/testing/_sourcetests/cachekey.py | 11 | ||||
-rw-r--r-- | src/buildstream/testing/repo.py | 2 | ||||
-rw-r--r-- | tests/testutils/repo/git.py | 17 |
3 files changed, 25 insertions, 5 deletions
diff --git a/src/buildstream/testing/_sourcetests/cachekey.py b/src/buildstream/testing/_sourcetests/cachekey.py index 3c8724476..7d0c21e2f 100644 --- a/src/buildstream/testing/_sourcetests/cachekey.py +++ b/src/buildstream/testing/_sourcetests/cachekey.py @@ -47,6 +47,9 @@ def test_cache_key(cli, tmpdir, datafiles, kind): test_elements = repo.get_element_and_keys_for_cache_key_stability_test() + if test_elements is NotImplemented: + pytest.skip("Source {} doesn't implement `get_element_and_keys_for_cache_key_stability_test`.") + expected_cache_keys = {} for index, (element, cache_key) in enumerate(test_elements): @@ -57,12 +60,12 @@ def test_cache_key(cli, tmpdir, datafiles, kind): result = cli.run( project=project, silent=True, - args=["show", "--format", "%{name}::{%full-key}", *expected_cache_keys.keys()] + args=["show", "--format", "%{name}::%{full-key}", *expected_cache_keys.keys()] ) result.assert_success() - cache_keys = { - [l.split("::") for l in result.output.splitlines()] - } + cache_keys = dict( + l.split("::") for l in result.output.splitlines() + ) error_msg = """\ A cache key needs an update, some keys have changes. diff --git a/src/buildstream/testing/repo.py b/src/buildstream/testing/repo.py index a190429ed..b80cc9e83 100644 --- a/src/buildstream/testing/repo.py +++ b/src/buildstream/testing/repo.py @@ -119,4 +119,4 @@ class Repo: This ensures that sources don't unintentionally break their cache keys and that BuildStream itself doesn't either. """ - raise NotImplementedError("Element cache keys tests should be implemented") + return NotImplemented diff --git a/tests/testutils/repo/git.py b/tests/testutils/repo/git.py index 1deca3ff7..f8af28e33 100644 --- a/tests/testutils/repo/git.py +++ b/tests/testutils/repo/git.py @@ -107,3 +107,20 @@ class Git(Repo): def rev_parse(self, rev): return self._run_git("rev-parse", rev, stdout=subprocess.PIPE, universal_newlines=True,).stdout.strip() + + def get_element_and_keys_for_cache_key_stability_test(self): + return [ + ( + { + "kind": "import", + "sources": [ + { + "kind": "git", + "url": "https://example.com/git/repo.git", + "ref": "6ac68af3e80b7b17c23a3c65233043550a7fa685" + } + ] + }, + "4e21bc1089066998d44933fdf1e48b2a5a73ceaba7a3944538f3f142e34b8b8e" + ) + ] |