summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandan Singh <chandan@chandansingh.net>2020-05-07 20:37:00 +0000
committerChandan Singh <chandan@chandansingh.net>2020-05-13 21:32:43 +0000
commitf196019a47b27b7a686e3aa1a1e03530fef28ea2 (patch)
treeeb88ccaafe9eba62c2990feb108ca80fc1ce1573
parentc3198f5e4e8ff45ac9be19215f575a54e2180de4 (diff)
downloadbuildstream-f196019a47b27b7a686e3aa1a1e03530fef28ea2.tar.gz
_frontend/cli: Support "build" and "run" values for `artifact pull --deps`
-rw-r--r--NEWS1
-rw-r--r--src/buildstream/_frontend/cli.py7
-rw-r--r--tests/frontend/pull.py28
3 files changed, 27 insertions, 9 deletions
diff --git a/NEWS b/NEWS
index 9f5f94ab4..98fefc044 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ CLI
o `bst shell --build` will now automatically fetch missing sources.
o `bst build --deps` now also accepts "build" as an input.
o `bst source fetch --deps` now also accepts "build" and "run" as inputs.
+ o `bst artifact pull --deps` now also accepts "build" and "run" as inputs.
Format
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py
index f3499a56c..34e21fd22 100644
--- a/src/buildstream/_frontend/cli.py
+++ b/src/buildstream/_frontend/cli.py
@@ -1301,7 +1301,10 @@ def artifact_checkout(app, force, deps, integrate, hardlinks, tar, compression,
"-d",
default=_PipelineSelection.NONE,
show_default=True,
- type=FastEnumType(_PipelineSelection, [_PipelineSelection.NONE, _PipelineSelection.ALL]),
+ type=FastEnumType(
+ _PipelineSelection,
+ [_PipelineSelection.BUILD, _PipelineSelection.NONE, _PipelineSelection.RUN, _PipelineSelection.ALL],
+ ),
help="The dependency artifacts to pull",
)
@click.option(
@@ -1327,6 +1330,8 @@ def artifact_pull(app, artifacts, deps, remote):
\b
none: No dependencies, just the element itself
+ run: Runtime dependencies, including the element itself
+ build: Build time dependencies, excluding the element itself
all: All dependencies
"""
diff --git a/tests/frontend/pull.py b/tests/frontend/pull.py
index e38cd1bcb..2f8d7a5ba 100644
--- a/tests/frontend/pull.py
+++ b/tests/frontend/pull.py
@@ -24,22 +24,33 @@ DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
# Tests that:
#
# * `bst build` pushes all build elements to configured 'push' cache
-# * `bst artifact pull --deps all` downloads everything from cache after local deletion
+# * `bst artifact pull --deps DEPS` downloads necessary artifacts from the cache
#
@pytest.mark.datafiles(DATA_DIR)
-def test_push_pull_all(cli, tmpdir, datafiles):
+@pytest.mark.parametrize(
+ "deps, expected_states",
+ [
+ ("build", ("buildable", "cached", "buildable")),
+ ("none", ("cached", "buildable", "buildable")),
+ ("run", ("cached", "buildable", "cached")),
+ ("all", ("cached", "cached", "cached")),
+ ],
+)
+def test_push_pull_deps(cli, tmpdir, datafiles, deps, expected_states):
project = str(datafiles)
+ target = "checkout-deps.bst"
+ build_dep = "import-dev.bst"
+ runtime_dep = "import-bin.bst"
+ all_elements = [target, build_dep, runtime_dep]
with create_artifact_share(os.path.join(str(tmpdir), "artifactshare")) as share:
# First build the target element and push to the remote.
cli.configure({"artifacts": {"url": share.repo, "push": True}})
- result = cli.run(project=project, args=["build", "target.bst"])
+ result = cli.run(project=project, args=["build", target])
result.assert_success()
- assert cli.get_element_state(project, "target.bst") == "cached"
# Assert that everything is now cached in the remote.
- all_elements = ["target.bst", "import-bin.bst", "import-dev.bst", "compose-all.bst"]
for element_name in all_elements:
assert_shared(cli, share, project, element_name)
@@ -56,12 +67,13 @@ def test_push_pull_all(cli, tmpdir, datafiles):
assert not any(states[e] == "cached" for e in all_elements)
# Now try bst artifact pull
- result = cli.run(project=project, args=["artifact", "pull", "--deps", "all", "target.bst"])
+ result = cli.run(project=project, args=["artifact", "pull", "--deps", deps, target])
result.assert_success()
- # And assert that it's again in the local cache, without having built
+ # And assert that the pulled elements are again in the local cache
states = cli.get_element_states(project, all_elements)
- assert not any(states[e] != "cached" for e in all_elements)
+ states_flattended = (states[target], states[build_dep], states[runtime_dep])
+ assert states_flattended == expected_states
# Tests that: