summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbst-marge-bot <marge-bot@buildstream.build>2020-05-14 12:59:17 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2020-05-14 12:59:17 +0000
commitdd2eb18bfc60cef39c9aa478397a4ff9a6c87a1d (patch)
tree255f1e6b3ff0c9d3dd14e57fdbed85e13d8e14ba
parent0769103ca25f113ab8e64bafb264781199a4dcac (diff)
parent3f08bb2c5909a39ca4ca532367033f9d0a090f11 (diff)
downloadbuildstream-dd2eb18bfc60cef39c9aa478397a4ff9a6c87a1d.tar.gz
Merge branch 'chandan/cli-deps-2' into 'master'
CLI: Add support for `--deps build` and `--deps run` in more commands See merge request BuildStream/buildstream!1904
-rw-r--r--NEWS4
-rw-r--r--man/bst-artifact-checkout.12
-rw-r--r--man/bst-artifact-delete.12
-rw-r--r--man/bst-artifact-list-contents.12
-rw-r--r--man/bst-artifact-log.12
-rw-r--r--man/bst-artifact-pull.16
-rw-r--r--man/bst-artifact-push.16
-rw-r--r--man/bst-artifact-server.12
-rw-r--r--man/bst-artifact-show.12
-rw-r--r--man/bst-artifact.12
-rw-r--r--man/bst-build.15
-rw-r--r--man/bst-help.12
-rw-r--r--man/bst-init.16
-rw-r--r--man/bst-shell.12
-rw-r--r--man/bst-show.12
-rw-r--r--man/bst-source-checkout.12
-rw-r--r--man/bst-source-fetch.16
-rw-r--r--man/bst-source-track.12
-rw-r--r--man/bst-source.12
-rw-r--r--man/bst-workspace-close.12
-rw-r--r--man/bst-workspace-list.12
-rw-r--r--man/bst-workspace-open.12
-rw-r--r--man/bst-workspace-reset.12
-rw-r--r--man/bst-workspace.12
-rw-r--r--man/bst.12
-rw-r--r--src/buildstream/_frontend/cli.py32
-rw-r--r--tests/frontend/buildcheckout.py16
-rw-r--r--tests/frontend/fetch.py41
-rw-r--r--tests/frontend/pull.py28
-rw-r--r--tests/frontend/push.py35
-rw-r--r--tests/frontend/source-fetch/apples.bst6
-rw-r--r--tests/frontend/source-fetch/bananas.bst12
-rw-r--r--tests/frontend/source-fetch/files/apples1
-rw-r--r--tests/frontend/source-fetch/files/bananas1
-rw-r--r--tests/frontend/source-fetch/files/oranges1
-rw-r--r--tests/frontend/source-fetch/oranges.bst6
36 files changed, 196 insertions, 54 deletions
diff --git a/NEWS b/NEWS
index 10563b127..2aa5e32f9 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ 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.
+ o `bst artifact push --deps` now also accepts "build" and "run" as inputs.
Format
diff --git a/man/bst-artifact-checkout.1 b/man/bst-artifact-checkout.1
index 098646d35..51f537f69 100644
--- a/man/bst-artifact-checkout.1
+++ b/man/bst-artifact-checkout.1
@@ -1,4 +1,4 @@
-.TH "BST ARTIFACT CHECKOUT" "1" "2020-04-23" "" "bst artifact checkout Manual"
+.TH "BST ARTIFACT CHECKOUT" "1" "2020-05-07" "" "bst artifact checkout Manual"
.SH NAME
bst\-artifact\-checkout \- Checkout contents of an artifact
.SH SYNOPSIS
diff --git a/man/bst-artifact-delete.1 b/man/bst-artifact-delete.1
index 4e69397b6..8b92499f8 100644
--- a/man/bst-artifact-delete.1
+++ b/man/bst-artifact-delete.1
@@ -1,4 +1,4 @@
-.TH "BST ARTIFACT DELETE" "1" "2020-04-23" "" "bst artifact delete Manual"
+.TH "BST ARTIFACT DELETE" "1" "2020-05-07" "" "bst artifact delete Manual"
.SH NAME
bst\-artifact\-delete \- Remove artifacts from the local cache
.SH SYNOPSIS
diff --git a/man/bst-artifact-list-contents.1 b/man/bst-artifact-list-contents.1
index bb6e8c3f6..b53df3073 100644
--- a/man/bst-artifact-list-contents.1
+++ b/man/bst-artifact-list-contents.1
@@ -1,4 +1,4 @@
-.TH "BST ARTIFACT LIST-CONTENTS" "1" "2020-04-23" "" "bst artifact list-contents Manual"
+.TH "BST ARTIFACT LIST-CONTENTS" "1" "2020-05-07" "" "bst artifact list-contents Manual"
.SH NAME
bst\-artifact\-list-contents \- List the contents of an artifact
.SH SYNOPSIS
diff --git a/man/bst-artifact-log.1 b/man/bst-artifact-log.1
index 145440b87..84153fc38 100644
--- a/man/bst-artifact-log.1
+++ b/man/bst-artifact-log.1
@@ -1,4 +1,4 @@
-.TH "BST ARTIFACT LOG" "1" "2020-04-23" "" "bst artifact log Manual"
+.TH "BST ARTIFACT LOG" "1" "2020-05-07" "" "bst artifact log Manual"
.SH NAME
bst\-artifact\-log \- Show logs of artifacts
.SH SYNOPSIS
diff --git a/man/bst-artifact-pull.1 b/man/bst-artifact-pull.1
index e9b16cd72..d58346aac 100644
--- a/man/bst-artifact-pull.1
+++ b/man/bst-artifact-pull.1
@@ -1,4 +1,4 @@
-.TH "BST ARTIFACT PULL" "1" "2020-04-23" "" "bst artifact pull Manual"
+.TH "BST ARTIFACT PULL" "1" "2020-05-07" "" "bst artifact pull Manual"
.SH NAME
bst\-artifact\-pull \- Pull a built artifact
.SH SYNOPSIS
@@ -22,10 +22,12 @@ Specify `--deps` to control which artifacts to pull:
.PP

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
.SH OPTIONS
.TP
-\fB\-d,\fP \-\-deps [none|all]
+\fB\-d,\fP \-\-deps [build|none|run|all]
The dependency artifacts to pull [default: none]
.TP
\fB\-r,\fP \-\-remote TEXT
diff --git a/man/bst-artifact-push.1 b/man/bst-artifact-push.1
index 75f394d58..88cf96abf 100644
--- a/man/bst-artifact-push.1
+++ b/man/bst-artifact-push.1
@@ -1,4 +1,4 @@
-.TH "BST ARTIFACT PUSH" "1" "2020-04-23" "" "bst artifact push Manual"
+.TH "BST ARTIFACT PUSH" "1" "2020-05-07" "" "bst artifact push Manual"
.SH NAME
bst\-artifact\-push \- Push a built artifact
.SH SYNOPSIS
@@ -25,10 +25,12 @@ Specify `--deps` to control which artifacts to push:
.PP

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
.SH OPTIONS
.TP
-\fB\-d,\fP \-\-deps [none|all]
+\fB\-d,\fP \-\-deps [build|none|run|all]
The dependencies to push [default: none]
.TP
\fB\-r,\fP \-\-remote TEXT
diff --git a/man/bst-artifact-server.1 b/man/bst-artifact-server.1
index 45fc5ff39..7d3735847 100644
--- a/man/bst-artifact-server.1
+++ b/man/bst-artifact-server.1
@@ -1,4 +1,4 @@
-.TH "BST-ARTIFACT-SERVER" "1" "2020-04-23" "" "bst-artifact-server Manual"
+.TH "BST-ARTIFACT-SERVER" "1" "2020-05-07" "" "bst-artifact-server Manual"
.SH NAME
bst-artifact-server \- CAS Artifact Server
.SH SYNOPSIS
diff --git a/man/bst-artifact-show.1 b/man/bst-artifact-show.1
index ee5b51bd4..660c9dc93 100644
--- a/man/bst-artifact-show.1
+++ b/man/bst-artifact-show.1
@@ -1,4 +1,4 @@
-.TH "BST ARTIFACT SHOW" "1" "2020-04-23" "" "bst artifact show Manual"
+.TH "BST ARTIFACT SHOW" "1" "2020-05-07" "" "bst artifact show Manual"
.SH NAME
bst\-artifact\-show \- Show the cached state of artifacts
.SH SYNOPSIS
diff --git a/man/bst-artifact.1 b/man/bst-artifact.1
index 13e21d122..3bdbddadb 100644
--- a/man/bst-artifact.1
+++ b/man/bst-artifact.1
@@ -1,4 +1,4 @@
-.TH "BST ARTIFACT" "1" "2020-04-23" "" "bst artifact Manual"
+.TH "BST ARTIFACT" "1" "2020-05-07" "" "bst artifact Manual"
.SH NAME
bst\-artifact \- Manipulate cached artifacts.
.SH SYNOPSIS
diff --git a/man/bst-build.1 b/man/bst-build.1
index 3e9722bc1..34ed95e41 100644
--- a/man/bst-build.1
+++ b/man/bst-build.1
@@ -1,4 +1,4 @@
-.TH "BST BUILD" "1" "2020-04-23" "" "bst build Manual"
+.TH "BST BUILD" "1" "2020-05-07" "" "bst build Manual"
.SH NAME
bst\-build \- Build elements in a pipeline
.SH SYNOPSIS
@@ -18,10 +18,11 @@ Specify `--deps` to control which dependencies to build:
.PP

plan: Only dependencies required for the build plan
+ build: Build time dependencies, excluding the element itself
all: All dependencies
.SH OPTIONS
.TP
-\fB\-d,\fP \-\-deps [plan|all]
+\fB\-d,\fP \-\-deps [build|plan|all]
The dependencies to build
.TP
\fB\-r,\fP \-\-remote TEXT
diff --git a/man/bst-help.1 b/man/bst-help.1
index 68772f6ec..a5a72983a 100644
--- a/man/bst-help.1
+++ b/man/bst-help.1
@@ -1,4 +1,4 @@
-.TH "BST HELP" "1" "2020-04-23" "" "bst help Manual"
+.TH "BST HELP" "1" "2020-05-07" "" "bst help Manual"
.SH NAME
bst\-help \- Print usage information
.SH SYNOPSIS
diff --git a/man/bst-init.1 b/man/bst-init.1
index 75d0f1812..cc2735799 100644
--- a/man/bst-init.1
+++ b/man/bst-init.1
@@ -1,4 +1,4 @@
-.TH "BST INIT" "1" "2020-04-23" "" "bst init Manual"
+.TH "BST INIT" "1" "2020-05-07" "" "bst init Manual"
.SH NAME
bst\-init \- Initialize a new BuildStream project
.SH SYNOPSIS
@@ -17,8 +17,8 @@ interactive session.
\fB\-\-project\-name\fP TEXT
The project name to use
.TP
-\fB\-\-format\-version\fP INTEGER
-The required format version [default: 25]
+\fB\-\-min\-version\fP TEXT
+The required format version [default: 2.0]
.TP
\fB\-\-element\-path\fP PATH
The subdirectory to store elements in [default: elements]
diff --git a/man/bst-shell.1 b/man/bst-shell.1
index ff6179a52..33474bc75 100644
--- a/man/bst-shell.1
+++ b/man/bst-shell.1
@@ -1,4 +1,4 @@
-.TH "BST SHELL" "1" "2020-04-23" "" "bst shell Manual"
+.TH "BST SHELL" "1" "2020-05-07" "" "bst shell Manual"
.SH NAME
bst\-shell \- Shell into an element's sandbox environment
.SH SYNOPSIS
diff --git a/man/bst-show.1 b/man/bst-show.1
index f81f73007..d100c7c8e 100644
--- a/man/bst-show.1
+++ b/man/bst-show.1
@@ -1,4 +1,4 @@
-.TH "BST SHOW" "1" "2020-04-23" "" "bst show Manual"
+.TH "BST SHOW" "1" "2020-05-07" "" "bst show Manual"
.SH NAME
bst\-show \- Show elements in the pipeline
.SH SYNOPSIS
diff --git a/man/bst-source-checkout.1 b/man/bst-source-checkout.1
index 7596d44c1..f843baa3c 100644
--- a/man/bst-source-checkout.1
+++ b/man/bst-source-checkout.1
@@ -1,4 +1,4 @@
-.TH "BST SOURCE CHECKOUT" "1" "2020-04-23" "" "bst source checkout Manual"
+.TH "BST SOURCE CHECKOUT" "1" "2020-05-07" "" "bst source checkout Manual"
.SH NAME
bst\-source\-checkout \- Checkout sources of an element
.SH SYNOPSIS
diff --git a/man/bst-source-fetch.1 b/man/bst-source-fetch.1
index bbffa2505..3059befb7 100644
--- a/man/bst-source-fetch.1
+++ b/man/bst-source-fetch.1
@@ -1,4 +1,4 @@
-.TH "BST SOURCE FETCH" "1" "2020-04-23" "" "bst source fetch Manual"
+.TH "BST SOURCE FETCH" "1" "2020-05-07" "" "bst source fetch Manual"
.SH NAME
bst\-source\-fetch \- Fetch sources in a pipeline
.SH SYNOPSIS
@@ -24,13 +24,15 @@ Specify `--deps` to control which sources to fetch:

none: No dependencies, just the element itself
plan: Only dependencies required for the build plan
+ run: Runtime dependencies, including the element itself
+ build: Build time dependencies, excluding the element itself
all: All dependencies
.SH OPTIONS
.TP
\fB\-\-except\fP PATH
Except certain dependencies from fetching
.TP
-\fB\-d,\fP \-\-deps [none|plan|all]
+\fB\-d,\fP \-\-deps [plan|none|build|run|all]
The dependencies to fetch [default: plan]
.TP
\fB\-r,\fP \-\-remote TEXT
diff --git a/man/bst-source-track.1 b/man/bst-source-track.1
index bb5a5e835..6863efc45 100644
--- a/man/bst-source-track.1
+++ b/man/bst-source-track.1
@@ -1,4 +1,4 @@
-.TH "BST SOURCE TRACK" "1" "2020-04-23" "" "bst source track Manual"
+.TH "BST SOURCE TRACK" "1" "2020-05-07" "" "bst source track Manual"
.SH NAME
bst\-source\-track \- Track new source references
.SH SYNOPSIS
diff --git a/man/bst-source.1 b/man/bst-source.1
index 4cf43bf64..adabef759 100644
--- a/man/bst-source.1
+++ b/man/bst-source.1
@@ -1,4 +1,4 @@
-.TH "BST SOURCE" "1" "2020-04-23" "" "bst source Manual"
+.TH "BST SOURCE" "1" "2020-05-07" "" "bst source Manual"
.SH NAME
bst\-source \- Manipulate sources for an element
.SH SYNOPSIS
diff --git a/man/bst-workspace-close.1 b/man/bst-workspace-close.1
index 7efde7960..63e071507 100644
--- a/man/bst-workspace-close.1
+++ b/man/bst-workspace-close.1
@@ -1,4 +1,4 @@
-.TH "BST WORKSPACE CLOSE" "1" "2020-04-23" "" "bst workspace close Manual"
+.TH "BST WORKSPACE CLOSE" "1" "2020-05-07" "" "bst workspace close Manual"
.SH NAME
bst\-workspace\-close \- Close workspaces
.SH SYNOPSIS
diff --git a/man/bst-workspace-list.1 b/man/bst-workspace-list.1
index 406a289d0..bad96bc72 100644
--- a/man/bst-workspace-list.1
+++ b/man/bst-workspace-list.1
@@ -1,4 +1,4 @@
-.TH "BST WORKSPACE LIST" "1" "2020-04-23" "" "bst workspace list Manual"
+.TH "BST WORKSPACE LIST" "1" "2020-05-07" "" "bst workspace list Manual"
.SH NAME
bst\-workspace\-list \- List open workspaces
.SH SYNOPSIS
diff --git a/man/bst-workspace-open.1 b/man/bst-workspace-open.1
index d94aaa5de..34993b841 100644
--- a/man/bst-workspace-open.1
+++ b/man/bst-workspace-open.1
@@ -1,4 +1,4 @@
-.TH "BST WORKSPACE OPEN" "1" "2020-04-23" "" "bst workspace open Manual"
+.TH "BST WORKSPACE OPEN" "1" "2020-05-07" "" "bst workspace open Manual"
.SH NAME
bst\-workspace\-open \- Open a new workspace
.SH SYNOPSIS
diff --git a/man/bst-workspace-reset.1 b/man/bst-workspace-reset.1
index 0ae76e09f..e0e86e87a 100644
--- a/man/bst-workspace-reset.1
+++ b/man/bst-workspace-reset.1
@@ -1,4 +1,4 @@
-.TH "BST WORKSPACE RESET" "1" "2020-04-23" "" "bst workspace reset Manual"
+.TH "BST WORKSPACE RESET" "1" "2020-05-07" "" "bst workspace reset Manual"
.SH NAME
bst\-workspace\-reset \- Reset a workspace to its original state
.SH SYNOPSIS
diff --git a/man/bst-workspace.1 b/man/bst-workspace.1
index 69a110f36..1f881e20b 100644
--- a/man/bst-workspace.1
+++ b/man/bst-workspace.1
@@ -1,4 +1,4 @@
-.TH "BST WORKSPACE" "1" "2020-04-23" "" "bst workspace Manual"
+.TH "BST WORKSPACE" "1" "2020-05-07" "" "bst workspace Manual"
.SH NAME
bst\-workspace \- Manipulate developer workspaces
.SH SYNOPSIS
diff --git a/man/bst.1 b/man/bst.1
index 711b306fa..c1ca5c88c 100644
--- a/man/bst.1
+++ b/man/bst.1
@@ -1,4 +1,4 @@
-.TH "BST" "1" "2020-04-23" "" "bst Manual"
+.TH "BST" "1" "2020-05-07" "" "bst Manual"
.SH NAME
bst \- Build and manipulate BuildStream projects...
.SH SYNOPSIS
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py
index e8e2112aa..11d6dfe98 100644
--- a/src/buildstream/_frontend/cli.py
+++ b/src/buildstream/_frontend/cli.py
@@ -460,7 +460,9 @@ def init(app, project_name, min_version, element_path, force, target_directory):
"--deps",
"-d",
default=None,
- type=FastEnumType(_PipelineSelection, [_PipelineSelection.PLAN, _PipelineSelection.ALL]),
+ type=FastEnumType(
+ _PipelineSelection, [_PipelineSelection.BUILD, _PipelineSelection.PLAN, _PipelineSelection.ALL],
+ ),
help="The dependencies to build",
)
@click.option(
@@ -482,6 +484,7 @@ def build(app, elements, deps, remote):
\b
plan: Only dependencies required for the build plan
+ build: Build time dependencies, excluding the element itself
all: All dependencies
"""
with app.initialized(session_name="Build"):
@@ -810,7 +813,16 @@ def source():
"-d",
default=_PipelineSelection.PLAN,
show_default=True,
- type=FastEnumType(_PipelineSelection, [_PipelineSelection.NONE, _PipelineSelection.PLAN, _PipelineSelection.ALL]),
+ type=FastEnumType(
+ _PipelineSelection,
+ [
+ _PipelineSelection.PLAN,
+ _PipelineSelection.NONE,
+ _PipelineSelection.BUILD,
+ _PipelineSelection.RUN,
+ _PipelineSelection.ALL,
+ ],
+ ),
help="The dependencies to fetch",
)
@click.option(
@@ -838,6 +850,8 @@ def source_fetch(app, elements, deps, except_, remote):
\b
none: No dependencies, just the element itself
plan: Only dependencies required for the build plan
+ run: Runtime dependencies, including the element itself
+ build: Build time dependencies, excluding the element itself
all: All dependencies
"""
with app.initialized(session_name="Fetch"):
@@ -1287,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(
@@ -1313,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
"""
@@ -1336,7 +1355,10 @@ def artifact_pull(app, artifacts, deps, remote):
"-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 dependencies to push",
)
@click.option(
@@ -1365,6 +1387,8 @@ def artifact_push(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
"""
with app.initialized(session_name="Push"):
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py
index 96c96ccfe..ca88a1368 100644
--- a/tests/frontend/buildcheckout.py
+++ b/tests/frontend/buildcheckout.py
@@ -189,6 +189,22 @@ def test_build_checkout_deps(datafiles, cli, deps):
@pytest.mark.datafiles(DATA_DIR)
+def test_build_deps_build(datafiles, cli):
+ project = str(datafiles)
+ target = "checkout-deps.bst"
+ build_dep = "import-dev.bst"
+ runtime_dep = "import-bin.bst"
+
+ result = cli.run(project=project, args=["build", "--deps", "build", target])
+ result.assert_success()
+
+ states = cli.get_element_states(project, [target, build_dep, runtime_dep])
+ assert states[build_dep] == "cached"
+ assert states[target] == "buildable"
+ assert states[runtime_dep] == "buildable"
+
+
+@pytest.mark.datafiles(DATA_DIR)
def test_build_checkout_unbuilt(datafiles, cli):
project = str(datafiles)
checkout = os.path.join(cli.directory, "checkout")
diff --git a/tests/frontend/fetch.py b/tests/frontend/fetch.py
index d6b28c589..b2c9d64c2 100644
--- a/tests/frontend/fetch.py
+++ b/tests/frontend/fetch.py
@@ -5,6 +5,7 @@ import os
import pytest
from buildstream.testing import cli # pylint: disable=unused-import
+from buildstream.testing import generate_project
from buildstream import _yaml
from buildstream.exceptions import ErrorDomain, LoadErrorReason
@@ -17,6 +18,46 @@ TOP_DIR = os.path.dirname(os.path.realpath(__file__))
DATA_DIR = os.path.join(TOP_DIR, "project")
+# Test all possible choices of the `--deps` option.
+#
+# NOTE: Elements used in this test must have sources that are not already
+# cached. The kind of the sources do not matter so long as they need to
+# be fetched from somewhere.
+# Currently we use remote sources for this purpose.
+#
+@pytest.mark.datafiles(os.path.join(TOP_DIR, "source-fetch"))
+@pytest.mark.parametrize(
+ "deps, expected_states",
+ [
+ ("build", ("fetch needed", "buildable", "fetch needed")),
+ ("none", ("waiting", "fetch needed", "fetch needed")),
+ ("run", ("waiting", "fetch needed", "buildable")),
+ ("all", ("waiting", "buildable", "buildable")),
+ ],
+)
+def test_fetch_deps(cli, datafiles, deps, expected_states):
+ project = str(datafiles)
+ generate_project(project)
+ generate_project(project, {"aliases": {"project-root": "file:///" + project}})
+
+ target = "bananas.bst"
+ build_dep = "apples.bst"
+ runtime_dep = "oranges.bst"
+
+ # Assert that none of the sources are cached
+ states = cli.get_element_states(project, [target, build_dep, runtime_dep])
+ assert all([state == "fetch needed" for state in states.values()])
+
+ # Now fetch the specified sources
+ result = cli.run(project=project, args=["source", "fetch", "--deps", deps, target])
+ result.assert_success()
+
+ # Finally assert that we have fetched _only_ the desired sources
+ states = cli.get_element_states(project, [target, build_dep, runtime_dep])
+ states_flattened = (states[target], states[build_dep], states[runtime_dep])
+ assert states_flattened == expected_states
+
+
@pytest.mark.datafiles(os.path.join(TOP_DIR, "consistencyerror"))
def test_fetch_consistency_error(cli, datafiles):
project = str(datafiles)
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:
diff --git a/tests/frontend/push.py b/tests/frontend/push.py
index 970885784..26dd6cb4f 100644
--- a/tests/frontend/push.py
+++ b/tests/frontend/push.py
@@ -220,21 +220,31 @@ def test_push_fails_with_on_error_continue(cli, tmpdir, datafiles):
assert error in result.stderr
-# Tests that `bst artifact push --deps all` pushes all dependencies of the given element.
+# Tests that `bst artifact push --deps DEPS` pushes selected dependencies of
+# the given element.
#
@pytest.mark.datafiles(DATA_DIR)
-def test_push_all(cli, tmpdir, datafiles):
+@pytest.mark.parametrize(
+ "deps, expected_states",
+ [
+ ("build", [False, True, False]),
+ ("none", [True, False, False]),
+ ("run", [True, False, True]),
+ ("all", [True, True, True]),
+ ],
+)
+def test_push_deps(cli, tmpdir, datafiles, deps, expected_states):
project = str(datafiles)
+ target = "checkout-deps.bst"
+ build_dep = "import-dev.bst"
+ runtime_dep = "import-bin.bst"
with create_artifact_share(os.path.join(str(tmpdir), "artifactshare")) as share:
# First build it without the artifact cache configured
- result = cli.run(project=project, args=["build", "target.bst"])
+ result = cli.run(project=project, args=["build", target])
result.assert_success()
- # Assert that we are now cached locally
- assert cli.get_element_state(project, "target.bst") == "cached"
-
# Configure artifact share
cli.configure(
{
@@ -252,14 +262,15 @@ def test_push_all(cli, tmpdir, datafiles):
)
# Now try bst artifact push all the deps
- result = cli.run(project=project, args=["artifact", "push", "target.bst", "--deps", "all"])
+ result = cli.run(project=project, args=["artifact", "push", target, "--deps", deps])
result.assert_success()
- # And finally assert that all the artifacts are in the share
- assert_shared(cli, share, project, "target.bst")
- assert_shared(cli, share, project, "import-bin.bst")
- assert_shared(cli, share, project, "import-dev.bst")
- assert_shared(cli, share, project, "compose-all.bst")
+ # And finally assert that the selected artifacts are in the share
+ states = []
+ for element in (target, build_dep, runtime_dep):
+ is_cached = share.get_artifact(cli.get_artifact_name(project, "test", element)) is not None
+ states.append(is_cached)
+ assert states == expected_states
# Tests that `bst artifact push --deps run $artifact_ref` fails
diff --git a/tests/frontend/source-fetch/apples.bst b/tests/frontend/source-fetch/apples.bst
new file mode 100644
index 000000000..61a0cdf56
--- /dev/null
+++ b/tests/frontend/source-fetch/apples.bst
@@ -0,0 +1,6 @@
+kind: import
+
+sources:
+- kind: remote
+ url: project-root:/files/apples
+ ref: 39ac5969800f779603237d01dc0be28dd795a33c591af6c7736264482265930a
diff --git a/tests/frontend/source-fetch/bananas.bst b/tests/frontend/source-fetch/bananas.bst
new file mode 100644
index 000000000..45416106f
--- /dev/null
+++ b/tests/frontend/source-fetch/bananas.bst
@@ -0,0 +1,12 @@
+kind: import
+
+build-depends:
+- apples.bst
+
+runtime-depends:
+- oranges.bst
+
+sources:
+- kind: remote
+ url: project-root:/files/bananas
+ ref: e49295702f7da8670778e9b95a281b72b41b31cb16afa376034b45f59a18ea3f
diff --git a/tests/frontend/source-fetch/files/apples b/tests/frontend/source-fetch/files/apples
new file mode 100644
index 000000000..950a188f0
--- /dev/null
+++ b/tests/frontend/source-fetch/files/apples
@@ -0,0 +1 @@
+apples
diff --git a/tests/frontend/source-fetch/files/bananas b/tests/frontend/source-fetch/files/bananas
new file mode 100644
index 000000000..9baf85eb7
--- /dev/null
+++ b/tests/frontend/source-fetch/files/bananas
@@ -0,0 +1 @@
+bananas
diff --git a/tests/frontend/source-fetch/files/oranges b/tests/frontend/source-fetch/files/oranges
new file mode 100644
index 000000000..192019cb7
--- /dev/null
+++ b/tests/frontend/source-fetch/files/oranges
@@ -0,0 +1 @@
+oranges
diff --git a/tests/frontend/source-fetch/oranges.bst b/tests/frontend/source-fetch/oranges.bst
new file mode 100644
index 000000000..35984edfd
--- /dev/null
+++ b/tests/frontend/source-fetch/oranges.bst
@@ -0,0 +1,6 @@
+kind: import
+
+sources:
+- kind: remote
+ url: project-root:/files/oranges
+ ref: b19fe3ce519db5b79021aed3e83d9533631d69b15813f9e198a4ba4a3107deaa