Chandan Singh pushed to branch chandan/deps at BuildStream / buildstream
Commits:
-
9b6c18e4
by Chandan Singh at 2019-02-12T10:20:52Z
3 changed files:
Changes:
... | ... | @@ -440,6 +440,9 @@ def show(app, elements, deps, except_, order, format_): |
440 | 440 |
%{public} Public domain data
|
441 | 441 |
%{workspaced} If the element is workspaced
|
442 | 442 |
%{workspace-dirs} A list of workspace directories
|
443 |
+ %{deps} A list of all dependencies
|
|
444 |
+ %{build-deps} A list of build dependencies
|
|
445 |
+ %{runtime-deps} A list of runtime dependencies
|
|
443 | 446 |
|
444 | 447 |
The value of the %{symbol} without the leading '%' character is understood
|
445 | 448 |
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
|
... | ... | @@ -435,6 +435,27 @@ class LogLine(Widget): |
435 | 435 |
line = p.fmt_subst(
|
436 | 436 |
line, 'workspace-dirs', '')
|
437 | 437 |
|
438 |
+ # Dependencies
|
|
439 |
+ if "%{deps" in format_:
|
|
440 |
+ deps = [e.name for e in element.dependencies(Scope.ALL, recurse=False)]
|
|
441 |
+ line = p.fmt_subst(
|
|
442 |
+ line, 'deps',
|
|
443 |
+ yaml.safe_dump(deps, default_style=None).rstrip('\n'))
|
|
444 |
+ |
|
445 |
+ # Build Dependencies
|
|
446 |
+ if "%{build-deps" in format_:
|
|
447 |
+ build_deps = [e.name for e in element.dependencies(Scope.BUILD, recurse=False)]
|
|
448 |
+ line = p.fmt_subst(
|
|
449 |
+ line, 'build-deps',
|
|
450 |
+ yaml.safe_dump(build_deps, default_style=False).rstrip('\n'))
|
|
451 |
+ |
|
452 |
+ # Runtime Dependencies
|
|
453 |
+ if "%{runtime-deps" in format_:
|
|
454 |
+ runtime_deps = [e.name for e in element.dependencies(Scope.RUN, recurse=False)]
|
|
455 |
+ line = p.fmt_subst(
|
|
456 |
+ line, 'runtime-deps',
|
|
457 |
+ yaml.safe_dump(runtime_deps, default_style=False).rstrip('\n'))
|
|
458 |
+ |
|
438 | 459 |
report += line + '\n'
|
439 | 460 |
|
440 | 461 |
return report.rstrip('\n')
|
... | ... | @@ -400,3 +400,28 @@ def test_exceed_max_recursion_depth(cli, tmpdir, dependency_depth): |
400 | 400 |
assert result.exit_code == -1
|
401 | 401 |
|
402 | 402 |
shutil.rmtree(project_path)
|
403 |
+ |
|
404 |
+ |
|
405 |
+###############################################################
|
|
406 |
+# Testing format symbols #
|
|
407 |
+###############################################################
|
|
408 |
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'project'))
|
|
409 |
+@pytest.mark.parametrize("dep_kind, expected_deps", [
|
|
410 |
+ ('%{deps}', '[import-dev.bst, import-bin.bst]'),
|
|
411 |
+ ('%{build-deps}', '[import-dev.bst]'),
|
|
412 |
+ ('%{runtime-deps}', '[import-bin.bst]')
|
|
413 |
+])
|
|
414 |
+def test_format_deps(cli, datafiles, dep_kind, expected_deps):
|
|
415 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
416 |
+ target = 'checkout-deps.bst'
|
|
417 |
+ result = cli.run(project=project, silent=True, args=[
|
|
418 |
+ 'show',
|
|
419 |
+ '--deps', 'none',
|
|
420 |
+ '--format', '%{name}: ' + dep_kind,
|
|
421 |
+ target])
|
|
422 |
+ result.assert_success()
|
|
423 |
+ |
|
424 |
+ expected = '{name}: {deps}'.format(name=target, deps=expected_deps)
|
|
425 |
+ if result.output.strip() != expected:
|
|
426 |
+ raise AssertionError("Expected output:\n{}\nInstead received output:\n{}"
|
|
427 |
+ .format(expected, result.output))
|