Chandan Singh pushed to branch chandan/deps at BuildStream / buildstream
Commits:
-
2cde2731
by Chandan Singh at 2019-01-31T14:23:10Z
3 changed files:
Changes:
... | ... | @@ -437,6 +437,9 @@ def show(app, elements, deps, except_, order, format_): |
437 | 437 |
%{public} Public domain data
|
438 | 438 |
%{workspaced} If the element is workspaced
|
439 | 439 |
%{workspace-dirs} A list of workspace directories
|
440 |
+ %{deps} A list of all dependencies
|
|
441 |
+ %{build-deps} A list of build dependencies
|
|
442 |
+ %{runtime-deps} A list of runtime dependencies
|
|
440 | 443 |
|
441 | 444 |
The value of the %{symbol} without the leading '%' character is understood
|
442 | 445 |
as a pythonic formatting string, so python formatting features apply,
|
... | ... | @@ -27,7 +27,7 @@ from ruamel import yaml |
27 | 27 |
import click
|
28 | 28 |
|
29 | 29 |
from . import Profile
|
30 |
-from .. import Element, Consistency
|
|
30 |
+from .. import Element, Consistency, Scope
|
|
31 | 31 |
from .. import _yaml
|
32 | 32 |
from .. import __version__ as bst_version
|
33 | 33 |
from .._exceptions import ImplError
|
... | ... | @@ -422,6 +422,21 @@ class LogLine(Widget): |
422 | 422 |
line = p.fmt_subst(
|
423 | 423 |
line, 'workspace-dirs', '')
|
424 | 424 |
|
425 |
+ # Dependencies
|
|
426 |
+ if "%{deps" in format_:
|
|
427 |
+ deps = [e.name for e in element.dependencies(Scope.ALL, recurse=False)]
|
|
428 |
+ line = p.fmt_subst(line, 'deps', deps)
|
|
429 |
+ |
|
430 |
+ # Build Dependencies
|
|
431 |
+ if "%{build-deps" in format_:
|
|
432 |
+ build_deps = [e.name for e in element.dependencies(Scope.BUILD, recurse=False)]
|
|
433 |
+ line = p.fmt_subst(line, 'build-deps', build_deps)
|
|
434 |
+ |
|
435 |
+ # Runtime Dependencies
|
|
436 |
+ if "%{runtime-deps" in format_:
|
|
437 |
+ runtime_deps = [e.name for e in element.dependencies(Scope.RUN, recurse=False)]
|
|
438 |
+ line = p.fmt_subst(line, 'runtime-deps', runtime_deps)
|
|
439 |
+ |
|
425 | 440 |
report += line + '\n'
|
426 | 441 |
|
427 | 442 |
return report.rstrip('\n')
|
... | ... | @@ -399,3 +399,28 @@ def test_exceed_max_recursion_depth(cli, tmpdir, dependency_depth): |
399 | 399 |
assert result.exit_code == -1
|
400 | 400 |
|
401 | 401 |
shutil.rmtree(project_path)
|
402 |
+ |
|
403 |
+ |
|
404 |
+###############################################################
|
|
405 |
+# Tessting format symbols #
|
|
406 |
+###############################################################
|
|
407 |
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'project'))
|
|
408 |
+@pytest.mark.parametrize("dep_kind, expected_deps", [
|
|
409 |
+ ('%{deps}', ['import-dev.bst', 'import-bin.bst']),
|
|
410 |
+ ('%{build-deps}', ['import-dev.bst']),
|
|
411 |
+ ('%{runtime-deps}', ['import-bin.bst'])
|
|
412 |
+])
|
|
413 |
+def test_format_deps(cli, datafiles, dep_kind, expected_deps):
|
|
414 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
415 |
+ target = 'checkout-deps.bst'
|
|
416 |
+ result = cli.run(project=project, silent=True, args=[
|
|
417 |
+ 'show',
|
|
418 |
+ '--deps', 'none',
|
|
419 |
+ '--format', '%{name}: ' + dep_kind,
|
|
420 |
+ target])
|
|
421 |
+ result.assert_success()
|
|
422 |
+ |
|
423 |
+ expected = '{name}: {deps}'.format(name=target, deps=expected_deps)
|
|
424 |
+ if result.output.strip() != expected:
|
|
425 |
+ raise AssertionError("Expected output:\n{}\nInstead received output:\n{}"
|
|
426 |
+ .format(expected, result.output))
|