diff options
author | Jürg Billeter <j@bitron.ch> | 2020-04-17 09:10:42 +0000 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2020-04-17 09:10:42 +0000 |
commit | 5d0049a32b66a7bde39f0d264b4a4ffa1285cabb (patch) | |
tree | 81d20ec56dc8f3c1780e8b61f663a0be84385bb0 | |
parent | 431cd16a997a4f548d2f262031f8eefc947158e7 (diff) | |
parent | 954ede72dff852488315910d437c13f9ddf6d435 (diff) | |
download | buildstream-5d0049a32b66a7bde39f0d264b4a4ffa1285cabb.tar.gz |
Merge branch 'juerg/cache-key' into 'master'
element.py: Fix strong cache key calculation in non-strict mode
See merge request BuildStream/buildstream!1865
-rw-r--r-- | src/buildstream/element.py | 4 | ||||
-rw-r--r-- | tests/frontend/buildcheckout.py | 22 |
2 files changed, 24 insertions, 2 deletions
diff --git a/src/buildstream/element.py b/src/buildstream/element.py index 06581b652..a7ee40051 100644 --- a/src/buildstream/element.py +++ b/src/buildstream/element.py @@ -3013,7 +3013,7 @@ class Element(Plugin): # encode the dependency's weak cache key instead of it's name. # dependencies = [ - e._get_cache_key(strength=_KeyStrength.WEAK) + [e.project_name, e.name, e._get_cache_key(strength=_KeyStrength.WEAK)] if self.BST_STRICT_REBUILD or e in self.__strict_dependencies else [e.project_name, e.name] for e in self.dependencies(Scope.BUILD) @@ -3119,7 +3119,7 @@ class Element(Plugin): self.__cache_key = strong_key elif self.__assemble_scheduled or self.__assemble_done: # Artifact will or has been built, not downloaded - dependencies = [e._get_cache_key() for e in self.dependencies(Scope.BUILD)] + dependencies = [[e.project_name, e.name, e._get_cache_key()] for e in self.dependencies(Scope.BUILD)] self.__cache_key = self._calculate_cache_key(dependencies) if self.__cache_key is None: diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py index 52cf031ad..a64faeb9d 100644 --- a/tests/frontend/buildcheckout.py +++ b/tests/frontend/buildcheckout.py @@ -69,6 +69,28 @@ def test_build_checkout(datafiles, cli, strict, hardlinks): @pytest.mark.datafiles(DATA_DIR) +def test_non_strict_build_strict_checkout(datafiles, cli): + project = str(datafiles) + checkout = os.path.join(cli.directory, "checkout") + + # First build it in non-strict mode. + # As this is a clean build from scratch, the result and also the cache keys + # should be identical to a build in strict mode. + result = cli.run(project=project, args=["--no-strict", "build", "target.bst"]) + result.assert_success() + + # Now check it out in strict mode. + # This verifies that the clean build in non-strict mode produced an artifact + # matching the strict cache key. + result = cli.run(project=project, args=["artifact", "checkout", "target.bst", "--directory", checkout]) + result.assert_success() + + # Check that the executable hello file is found in the checkout + filename = os.path.join(checkout, "usr", "bin", "hello") + assert os.path.exists(filename) + + +@pytest.mark.datafiles(DATA_DIR) @pytest.mark.parametrize("strict,hardlinks", [("non-strict", "hardlinks"),]) def test_build_invalid_suffix(datafiles, cli, strict, hardlinks): project = str(datafiles) |