summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Dawson <phil.dawson@codethink.co.uk>2019-01-31 17:03:04 +0000
committerPhil Dawson <phildawson.0807@gmail.com>2019-02-01 14:25:44 +0000
commit51cec3da9779730e24cb0e9131ec023f162f3866 (patch)
tree7e1849b716833157dc58f5e2cd8b7b35be0354ae
parent583bd97d1d3a38529ce003faff434fc83d7cbe90 (diff)
downloadbuildstream-phil/cache-key-stability-test.tar.gz
tests/cachekey: Test cache keys are independent of target elementsphil/cache-key-stability-test
-rw-r--r--tests/cachekey/cachekey.py38
-rw-r--r--tests/cachekey/project/elements/key-stability/aaa.bst4
-rw-r--r--tests/cachekey/project/elements/key-stability/t1.bst6
-rw-r--r--tests/cachekey/project/elements/key-stability/t2.bst7
-rw-r--r--tests/cachekey/project/elements/key-stability/top-level.bst7
-rw-r--r--tests/cachekey/project/elements/key-stability/zzz.bst4
6 files changed, 66 insertions, 0 deletions
diff --git a/tests/cachekey/cachekey.py b/tests/cachekey/cachekey.py
index c278b9ca9..761ff0c76 100644
--- a/tests/cachekey/cachekey.py
+++ b/tests/cachekey/cachekey.py
@@ -214,3 +214,41 @@ def test_cache_key_fatal_warnings(cli, tmpdir, first_warnings, second_warnings,
second_keys = run_get_cache_key("second", second_warnings)
assert compare_cache_keys(first_keys, second_keys) == identical_keys
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_keys_stable_over_targets(cli, datafiles):
+ root_element = 'elements/key-stability/top-level.bst'
+ target1 = 'elements/key-stability/t1.bst'
+ target2 = 'elements/key-stability/t2.bst'
+
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ full_graph_result = cli.run(project=project, args=[
+ 'show',
+ '--format', '%{name}::%{full-key}',
+ root_element
+ ])
+ full_graph_result.assert_success()
+ all_cache_keys = parse_output_keys(full_graph_result.output)
+
+ ordering1_result = cli.run(project=project, args=[
+ 'show',
+ '--format', '%{name}::%{full-key}',
+ target1,
+ target2
+ ])
+ ordering1_result.assert_success()
+ ordering1_cache_keys = parse_output_keys(ordering1_result.output)
+
+ ordering2_result = cli.run(project=project, args=[
+ 'show',
+ '--format', '%{name}::%{full-key}',
+ target2,
+ target1
+ ])
+ ordering2_result.assert_success()
+ ordering2_cache_keys = parse_output_keys(ordering2_result.output)
+
+ for element in ordering1_cache_keys:
+ assert ordering1_cache_keys[element] == ordering2_cache_keys[element]
+ assert ordering1_cache_keys[element] == all_cache_keys[element]
diff --git a/tests/cachekey/project/elements/key-stability/aaa.bst b/tests/cachekey/project/elements/key-stability/aaa.bst
new file mode 100644
index 000000000..cecbc2730
--- /dev/null
+++ b/tests/cachekey/project/elements/key-stability/aaa.bst
@@ -0,0 +1,4 @@
+kind: import
+sources:
+- kind: local
+ path: elements/key-stability/aaa.bst
diff --git a/tests/cachekey/project/elements/key-stability/t1.bst b/tests/cachekey/project/elements/key-stability/t1.bst
new file mode 100644
index 000000000..1ec009cf1
--- /dev/null
+++ b/tests/cachekey/project/elements/key-stability/t1.bst
@@ -0,0 +1,6 @@
+kind: import
+sources:
+- kind: local
+ path: elements/key-stability/t1.bst
+depends:
+- elements/key-stability/zzz.bst
diff --git a/tests/cachekey/project/elements/key-stability/t2.bst b/tests/cachekey/project/elements/key-stability/t2.bst
new file mode 100644
index 000000000..66f729373
--- /dev/null
+++ b/tests/cachekey/project/elements/key-stability/t2.bst
@@ -0,0 +1,7 @@
+kind: import
+sources:
+- kind: local
+ path: elements/key-stability/t2.bst
+depends:
+- elements/key-stability/aaa.bst
+- elements/key-stability/zzz.bst
diff --git a/tests/cachekey/project/elements/key-stability/top-level.bst b/tests/cachekey/project/elements/key-stability/top-level.bst
new file mode 100644
index 000000000..68d8a0e4d
--- /dev/null
+++ b/tests/cachekey/project/elements/key-stability/top-level.bst
@@ -0,0 +1,7 @@
+kind: import
+sources:
+- kind: local
+ path: elements/key-stability/top-level.bst
+depends:
+- elements/key-stability/t1.bst
+- elements/key-stability/t2.bst
diff --git a/tests/cachekey/project/elements/key-stability/zzz.bst b/tests/cachekey/project/elements/key-stability/zzz.bst
new file mode 100644
index 000000000..7ff782006
--- /dev/null
+++ b/tests/cachekey/project/elements/key-stability/zzz.bst
@@ -0,0 +1,4 @@
+kind: import
+sources:
+- kind: local
+ path: elements/key-stability/zzz.bst