diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py index 8ff60df54..d03480ebd 100644 --- a/src/buildstream/_stream.py +++ b/src/buildstream/_stream.py @@ -271,7 +271,7 @@ def shell( elements = self.load_selection( (target,), selection=selection, - connect_artifact_cache=True, + connect_artifact_cache=pull_, connect_source_cache=True, artifact_remotes=artifact_remotes, source_remotes=source_remotes, @@ -670,7 +670,7 @@ def checkout( selection=selection, load_artifacts=True, attempt_artifact_metadata=True, - connect_artifact_cache=True, + connect_artifact_cache=pull, artifact_remotes=artifact_remotes, ignore_project_artifact_remotes=ignore_project_artifact_remotes, ) @@ -685,7 +685,7 @@ def checkout( self.query_cache(elements) - uncached_elts = [elt for elt in elements if not elt._cached()] + uncached_elts = [elt for elt in elements if elt._pull_pending()] if uncached_elts and pull: self._context.messenger.info("Attempting to fetch missing or incomplete artifact") self._reset() diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py index 628e886ef..72587b31f 100644 --- a/tests/frontend/buildcheckout.py +++ b/tests/frontend/buildcheckout.py @@ -148,6 +148,27 @@ def test_non_strict_pull_build_strict_checkout(datafiles, cli, tmpdir): assert os.path.exists(filename) +# Regression test for https://github.com/apache/buildstream/issues/1469 +# Test that artifact checkout without pull doesn't trigger a BUG in non-strict mode. +@pytest.mark.datafiles(DATA_DIR) +def test_non_strict_checkout_uncached(datafiles, cli, tmpdir): + project = str(datafiles) + checkout = os.path.join(cli.directory, "checkout") + + element_name = "target.bst" + + with create_artifact_share(os.path.join(str(tmpdir), "artifactshare")) as share: + + cli.configure({"artifacts": {"servers": [{"url": share.repo}]}}) + + # Attempt to checkout an uncached artifact with remote artifact server + # configured but pull disabled. + result = cli.run( + project=project, args=["--no-strict", "artifact", "checkout", element_name, "--directory", checkout] + ) + result.assert_main_error(ErrorDomain.STREAM, "uncached-checkout-attempt") + + @pytest.mark.datafiles(DATA_DIR) @pytest.mark.parametrize("strict,hardlinks", [("non-strict", "hardlinks"),]) def test_build_invalid_suffix(datafiles, cli, strict, hardlinks):