summaryrefslogtreecommitdiff
path: root/tests/frontend/show.py
diff options
context:
space:
mode:
authorChandan Singh <csingh43@bloomberg.net>2019-01-31 12:01:55 +0000
committerChandan Singh <csingh43@bloomberg.net>2019-02-12 15:50:52 +0530
commit9b6c18e45cf96fad15bc15d767c627124a1722ee (patch)
tree0a292ff505dca5c5b660e44eb80a3768bec86554 /tests/frontend/show.py
parent86a9048a587f67fbb562f1188f9d04db0c220f75 (diff)
downloadbuildstream-9b6c18e45cf96fad15bc15d767c627124a1722ee.tar.gz
_frontend: Allow printing dependencies using `bst show`
At present, there isn't an easy way to print anything from `bst show` that would give the users an idea of what the dependency graph looks like. One could use things like `--deps build`, but that will just print a list, without any information about the dependency edges. Add `%{deps}`, `%{build-deps}` and `%{runtime-deps}` format strings to `bst show` that would simply print the list of all dependencies, build dependencies and runtime dependencies respectively. Summary of changes: * buildstream/_frontend/cli.py: Add help for new format symbols. * buildstream/_frontend/widget.py: Add support for new format symbols for dependencies. * tests/frontend/show.py: Add tests for new format symbols.
Diffstat (limited to 'tests/frontend/show.py')
-rw-r--r--tests/frontend/show.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/frontend/show.py b/tests/frontend/show.py
index ad3ae3591..ac1edebd6 100644
--- a/tests/frontend/show.py
+++ b/tests/frontend/show.py
@@ -400,3 +400,28 @@ def test_exceed_max_recursion_depth(cli, tmpdir, dependency_depth):
assert result.exit_code == -1
shutil.rmtree(project_path)
+
+
+###############################################################
+# Testing format symbols #
+###############################################################
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'project'))
+@pytest.mark.parametrize("dep_kind, expected_deps", [
+ ('%{deps}', '[import-dev.bst, import-bin.bst]'),
+ ('%{build-deps}', '[import-dev.bst]'),
+ ('%{runtime-deps}', '[import-bin.bst]')
+])
+def test_format_deps(cli, datafiles, dep_kind, expected_deps):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ target = 'checkout-deps.bst'
+ result = cli.run(project=project, silent=True, args=[
+ 'show',
+ '--deps', 'none',
+ '--format', '%{name}: ' + dep_kind,
+ target])
+ result.assert_success()
+
+ expected = '{name}: {deps}'.format(name=target, deps=expected_deps)
+ if result.output.strip() != expected:
+ raise AssertionError("Expected output:\n{}\nInstead received output:\n{}"
+ .format(expected, result.output))