summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChandan Singh <chandan@chandansingh.net>2020-08-13 21:12:31 +0000
committerChandan Singh <chandan@chandansingh.net>2020-08-14 11:44:50 +0000
commitabd86159faaa2aaec839339f6a5ab77c8fc1bae8 (patch)
tree726d693425681de692d650b1cfc0d0cb638159d8 /tests
parent6daae554ddf6e1c3e25cdbaad6ac56c5398b8c84 (diff)
downloadbuildstream-abd86159faaa2aaec839339f6a5ab77c8fc1bae8.tar.gz
_frontend/cli: Add --deps `build` & `run` values for `source track --deps`
This is part of #1349. This patch will conclude the first part of that issue, i.e. ensuring that the possible options for `--deps` are consistent across all commands (with the exception of `--deps plan` that we will handle separately).
Diffstat (limited to 'tests')
-rw-r--r--tests/frontend/completions.py2
-rw-r--r--tests/frontend/source-track/apples.bst5
-rw-r--r--tests/frontend/source-track/bananas.bst11
-rw-r--r--tests/frontend/source-track/files/apples1
-rw-r--r--tests/frontend/source-track/files/bananas1
-rw-r--r--tests/frontend/source-track/files/oranges1
-rw-r--r--tests/frontend/source-track/oranges.bst5
-rw-r--r--tests/frontend/track.py41
8 files changed, 65 insertions, 2 deletions
diff --git a/tests/frontend/completions.py b/tests/frontend/completions.py
index 952ed177b..21ef3becc 100644
--- a/tests/frontend/completions.py
+++ b/tests/frontend/completions.py
@@ -150,7 +150,7 @@ def test_options(cli, cmd, word_idx, expected):
("bst show --deps b", 3, ["build "]),
("bst show --deps=b", 2, ["build "]),
("bst show --deps r", 3, ["run "]),
- ("bst source track --deps ", 4, ["all ", "none "]),
+ ("bst source track --deps ", 4, ["all ", "build ", "none ", "run "]),
],
)
def test_option_choice(cli, cmd, word_idx, expected):
diff --git a/tests/frontend/source-track/apples.bst b/tests/frontend/source-track/apples.bst
new file mode 100644
index 000000000..482b1e78e
--- /dev/null
+++ b/tests/frontend/source-track/apples.bst
@@ -0,0 +1,5 @@
+kind: import
+
+sources:
+- kind: remote
+ url: project-root:/files/apples
diff --git a/tests/frontend/source-track/bananas.bst b/tests/frontend/source-track/bananas.bst
new file mode 100644
index 000000000..71b714b7d
--- /dev/null
+++ b/tests/frontend/source-track/bananas.bst
@@ -0,0 +1,11 @@
+kind: import
+
+build-depends:
+- apples.bst
+
+runtime-depends:
+- oranges.bst
+
+sources:
+- kind: remote
+ url: project-root:/files/bananas
diff --git a/tests/frontend/source-track/files/apples b/tests/frontend/source-track/files/apples
new file mode 100644
index 000000000..950a188f0
--- /dev/null
+++ b/tests/frontend/source-track/files/apples
@@ -0,0 +1 @@
+apples
diff --git a/tests/frontend/source-track/files/bananas b/tests/frontend/source-track/files/bananas
new file mode 100644
index 000000000..9baf85eb7
--- /dev/null
+++ b/tests/frontend/source-track/files/bananas
@@ -0,0 +1 @@
+bananas
diff --git a/tests/frontend/source-track/files/oranges b/tests/frontend/source-track/files/oranges
new file mode 100644
index 000000000..192019cb7
--- /dev/null
+++ b/tests/frontend/source-track/files/oranges
@@ -0,0 +1 @@
+oranges
diff --git a/tests/frontend/source-track/oranges.bst b/tests/frontend/source-track/oranges.bst
new file mode 100644
index 000000000..56af0e579
--- /dev/null
+++ b/tests/frontend/source-track/oranges.bst
@@ -0,0 +1,5 @@
+kind: import
+
+sources:
+- kind: remote
+ url: project-root:/files/oranges
diff --git a/tests/frontend/track.py b/tests/frontend/track.py
index 5fe9bbde6..ba569d210 100644
--- a/tests/frontend/track.py
+++ b/tests/frontend/track.py
@@ -5,7 +5,7 @@ import stat
import os
import pytest
-from buildstream.testing import create_repo
+from buildstream.testing import create_repo, generate_project
from buildstream.testing import cli # pylint: disable=unused-import
from buildstream.exceptions import ErrorDomain, LoadErrorReason
from buildstream import _yaml
@@ -122,6 +122,45 @@ def test_track_optional(cli, tmpdir, datafiles, ref_storage):
assert test_key != master_key
+# Test all possible choices of the `--deps` option.
+#
+# NOTE: Elements used in this test must have sources that are trackable and do
+# not have a reference already. The kinds of the sources do not matter so
+# long as they can be tracked from somewhere.
+# Currently we use remote sources for this purpose.
+#
+@pytest.mark.datafiles(os.path.join(TOP_DIR, "source-track"))
+@pytest.mark.parametrize(
+ "deps, expected_states",
+ [
+ ("build", ("no reference", "buildable", "no reference")),
+ ("none", ("waiting", "no reference", "no reference")),
+ ("run", ("waiting", "no reference", "buildable")),
+ ("all", ("waiting", "buildable", "buildable")),
+ ],
+)
+def test_track_deps(cli, datafiles, deps, expected_states):
+ project = str(datafiles)
+ 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 have a reference
+ states = cli.get_element_states(project, [target, build_dep, runtime_dep])
+ assert all([state == "no reference" for state in states.values()])
+
+ # Now track the specified sources
+ result = cli.run(project=project, args=["source", "track", "--deps", deps, target])
+ result.assert_success()
+
+ # Finally assert that we have tracked _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, "track-cross-junction"))
@pytest.mark.parametrize("cross_junction", [("cross"), ("nocross")])
@pytest.mark.parametrize("ref_storage", [("inline"), ("project.refs")])