Chandan Singh pushed to branch chandan/junction-dependency-format at BuildStream / buildstream
Commits:
- 
9b6c18e4
by Chandan Singh at 2019-02-12T10:20:52Z
- 
126bc006
by Chandan Singh at 2019-02-12T10:23:44Z
- 
dbce3434
by Chandan Singh at 2019-02-12T12:19:57Z
- 
24d29a17
by Javier Jardón at 2019-02-12T12:27:42Z
- 
80dcf65d
by Javier Jardón at 2019-02-12T12:27:42Z
- 
58b84905
by Javier Jardón at 2019-02-12T12:27:42Z
- 
95d9b9ae
by Javier Jardón at 2019-02-12T13:31:56Z
- 
fd1d40bf
by Chandan Singh at 2019-02-12T14:59:00Z
- 
81c28b43
by Chandan Singh at 2019-02-12T14:59:00Z
- 
ab087df6
by Chandan Singh at 2019-02-12T14:59:00Z
30 changed files:
- .gitlab-ci.yml
- NEWS
- buildstream/_frontend/cli.py
- buildstream/_frontend/widget.py
- buildstream/_loader/types.py
- buildstream/_versions.py
- doc/source/format_declaring.rst
- man/bst-artifact-checkout.1
- man/bst-artifact-log.1
- man/bst-artifact-pull.1
- man/bst-artifact-push.1
- man/bst-artifact-server.1
- man/bst-artifact.1
- man/bst-build.1
- man/bst-help.1
- man/bst-init.1
- man/bst-shell.1
- man/bst-show.1
- man/bst-source-checkout.1
- man/bst-source-fetch.1
- man/bst-source-track.1
- man/bst-source.1
- man/bst-workspace-close.1
- man/bst-workspace-list.1
- man/bst-workspace-open.1
- man/bst-workspace-reset.1
- man/bst-workspace.1
- man/bst.1
- tests/frontend/buildcheckout.py
- tests/frontend/show.py
Changes:
| ... | ... | @@ -53,26 +53,20 @@ tests-fedora-28: | 
| 53 | 53 |    image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:28-master-46405991
 | 
| 54 | 54 |    <<: *tests
 | 
| 55 | 55 |  | 
| 56 | -tests-ubuntu-18.04:
 | |
| 57 | -  image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-ubuntu:18.04-master-46405991
 | |
| 56 | +tests-fedora-29:
 | |
| 57 | +  image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:29-master-47052095
 | |
| 58 | 58 |    <<: *tests
 | 
| 59 | 59 |  | 
| 60 | -tests-python-3.7-stretch:
 | |
| 61 | -  image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-python:3.7-stretch-master-46405991
 | |
| 60 | +tests-ubuntu-18.04:
 | |
| 61 | +  image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-ubuntu:18.04-master-46405991
 | |
| 62 | 62 |    <<: *tests
 | 
| 63 | 63 |  | 
| 64 | -  variables:
 | |
| 65 | -    # Note that we explicitly specify TOXENV in this case because this
 | |
| 66 | -    # image has both 3.6 and 3.7 versions. python3.6 cannot be removed because
 | |
| 67 | -    # some of our base dependencies declare it as their runtime dependency.
 | |
| 68 | -    TOXENV: py37
 | |
| 69 | - | |
| 70 | 64 |  tests-centos-7.6:
 | 
| 71 | 65 |    <<: *tests
 | 
| 72 | 66 |    image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-centos:7.6.1810-master-46405991
 | 
| 73 | 67 |  | 
| 74 | -overnight-fedora-28-aarch64:
 | |
| 75 | -  image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:aarch64-28-master-46405991
 | |
| 68 | +overnight-fedora-29-aarch64:
 | |
| 69 | +  image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:aarch64-29-master-47052095
 | |
| 76 | 70 |    tags:
 | 
| 77 | 71 |      - aarch64
 | 
| 78 | 72 |    <<: *tests
 | 
| ... | ... | @@ -91,7 +85,7 @@ overnight-fedora-28-aarch64: | 
| 91 | 85 |  tests-unix:
 | 
| 92 | 86 |    # Use fedora here, to a) run a test on fedora and b) ensure that we
 | 
| 93 | 87 |    # can get rid of ostree - this is not possible with debian-8
 | 
| 94 | -  image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:28-master-46405991
 | |
| 88 | +  image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:29-master-47052095
 | |
| 95 | 89 |    <<: *tests
 | 
| 96 | 90 |    variables:
 | 
| 97 | 91 |      BST_FORCE_BACKEND: "unix"
 | 
| ... | ... | @@ -109,7 +103,7 @@ tests-unix: | 
| 109 | 103 |  | 
| 110 | 104 |  tests-fedora-missing-deps:
 | 
| 111 | 105 |    # Ensure that tests behave nicely while missing bwrap and ostree
 | 
| 112 | -  image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:28-master-46405991
 | |
| 106 | +  image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:29-master-47052095
 | |
| 113 | 107 |    <<: *tests
 | 
| 114 | 108 |  | 
| 115 | 109 |    script:
 | 
| ... | ... | @@ -128,7 +122,7 @@ tests-fedora-update-deps: | 
| 128 | 122 |    # Check if the tests pass after updating requirements to their latest
 | 
| 129 | 123 |    # allowed version.
 | 
| 130 | 124 |    allow_failure: true
 | 
| 131 | -  image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:28-master-46405991
 | |
| 125 | +  image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:29-master-47052095
 | |
| 132 | 126 |    <<: *tests
 | 
| 133 | 127 |  | 
| 134 | 128 |    script:
 | 
| ... | ... | @@ -289,6 +283,7 @@ coverage: | 
| 289 | 283 |    dependencies:
 | 
| 290 | 284 |    - tests-debian-9
 | 
| 291 | 285 |    - tests-fedora-28
 | 
| 286 | +  - tests-fedora-29
 | |
| 292 | 287 |    - tests-fedora-missing-deps
 | 
| 293 | 288 |    - tests-ubuntu-18.04
 | 
| 294 | 289 |    - tests-unix
 | 
| ... | ... | @@ -70,6 +70,9 @@ buildstream 1.3.1 | 
| 70 | 70 |      to avoid having to specify the dependency type for every entry in
 | 
| 71 | 71 |      'depends'.
 | 
| 72 | 72 |  | 
| 73 | +  o Elements may now specify cross-junction dependencies as simple strings
 | |
| 74 | +    using the format '{junction-name}:{element-name}'.
 | |
| 75 | + | |
| 73 | 76 |    o Source plugins may now request access access to previous during track and
 | 
| 74 | 77 |      fetch by setting `BST_REQUIRES_PREVIOUS_SOURCES_TRACK` and/or
 | 
| 75 | 78 |      `BST_REQUIRES_PREVIOUS_SOURCES_FETCH` attributes.
 | 
| ... | ... | @@ -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')
 | 
| ... | ... | @@ -17,6 +17,8 @@ | 
| 17 | 17 |  #  Authors:
 | 
| 18 | 18 |  #        Tristan Van Berkom <tristan vanberkom codethink co uk>
 | 
| 19 | 19 |  | 
| 20 | +from .._exceptions import LoadError, LoadErrorReason
 | |
| 21 | + | |
| 20 | 22 |  | 
| 21 | 23 |  # Symbol():
 | 
| 22 | 24 |  #
 | 
| ... | ... | @@ -56,8 +58,22 @@ class Symbol(): | 
| 56 | 58 |  #                             dependency was declared
 | 
| 57 | 59 |  #
 | 
| 58 | 60 |  class Dependency():
 | 
| 59 | -    def __init__(self, name,
 | |
| 61 | +    def __init__(self, filename,
 | |
| 60 | 62 |                   dep_type=None, junction=None, provenance=None):
 | 
| 63 | +        # Attempt to split name if no junction was specified explicitly
 | |
| 64 | +        if not junction:
 | |
| 65 | +            junction_path = filename.rsplit(":", 1)
 | |
| 66 | +            name = junction_path[-1]
 | |
| 67 | +            junction = None if len(junction_path) == 1 else junction_path[-2]
 | |
| 68 | +        else:
 | |
| 69 | +            name = filename
 | |
| 70 | + | |
| 71 | +        # Name of the element should not contain any `:` characters at this stage
 | |
| 72 | +        if ':' in name:
 | |
| 73 | +            raise LoadError(LoadErrorReason.INVALID_DATA,
 | |
| 74 | +                            "Element {} contains `:` in its name. "
 | |
| 75 | +                            "Recursive lookups for cross-junction elements is not allowed.".format(filename))
 | |
| 76 | + | |
| 61 | 77 |          self.name = name
 | 
| 62 | 78 |          self.dep_type = dep_type
 | 
| 63 | 79 |          self.junction = junction
 | 
| ... | ... | @@ -23,7 +23,7 @@ | 
| 23 | 23 |  # This version is bumped whenever enhancements are made
 | 
| 24 | 24 |  # to the `project.conf` format or the core element format.
 | 
| 25 | 25 |  #
 | 
| 26 | -BST_FORMAT_VERSION = 21
 | |
| 26 | +BST_FORMAT_VERSION = 22
 | |
| 27 | 27 |  | 
| 28 | 28 |  | 
| 29 | 29 |  # The base BuildStream artifact version
 | 
| ... | ... | @@ -401,6 +401,40 @@ Attributes: | 
| 401 | 401 |       The ``junction`` attribute is available since :ref:`format version 1 <project_format_version>`
 | 
| 402 | 402 |  | 
| 403 | 403 |  | 
| 404 | +Cross-junction dependencies
 | |
| 405 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~
 | |
| 406 | +As mentioned above, cross-junction dependencies can be specified using the
 | |
| 407 | +``junction`` attribute. They can also be expressed as simple strings as a
 | |
| 408 | +convenience shorthand. You can refer to cross-junction elements using the
 | |
| 409 | +syntax ``{junction-name}:{element-name}``.
 | |
| 410 | + | |
| 411 | +For example, the following is logically same as the example above:
 | |
| 412 | + | |
| 413 | +.. code:: yaml
 | |
| 414 | + | |
| 415 | +   build-depends:
 | |
| 416 | +     - baseproject.bst:foo.bst
 | |
| 417 | + | |
| 418 | +Similarly, you can also refer to cross-junction elements via the ``filename``
 | |
| 419 | +attribute, like so:
 | |
| 420 | + | |
| 421 | +.. code:: yaml
 | |
| 422 | + | |
| 423 | +   depends:
 | |
| 424 | +     - filename: baseproject.bst:foo.bst
 | |
| 425 | +       type: build
 | |
| 426 | + | |
| 427 | +.. note::
 | |
| 428 | + | |
| 429 | +   Recursive lookups are not allowed using this syntax. If a filename
 | |
| 430 | +   contains more than one ``:`` (colon) character, BuildStream will raise
 | |
| 431 | +   an error.
 | |
| 432 | + | |
| 433 | +.. note::
 | |
| 434 | + | |
| 435 | +   This shorthand is available since :ref:`format version 22 <project_format_version>`
 | |
| 436 | + | |
| 437 | + | |
| 404 | 438 |  .. _format_dependencies_types:
 | 
| 405 | 439 |  | 
| 406 | 440 |  Dependency types
 | 
| 1 | -.TH "BST ARTIFACT CHECKOUT" "1" "24-Jan-2019" "" "bst artifact checkout Manual"
 | |
| 1 | +.TH "BST ARTIFACT CHECKOUT" "1" "12-Feb-2019" "" "bst artifact checkout Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst\-artifact\-checkout \- Checkout contents of an artifact
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| 1 | -.TH "BST ARTIFACT LOG" "1" "24-Jan-2019" "" "bst artifact log Manual"
 | |
| 1 | +.TH "BST ARTIFACT LOG" "1" "12-Feb-2019" "" "bst artifact log Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst\-artifact\-log \- Show logs of an artifact
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| 1 | -.TH "BST ARTIFACT PULL" "1" "24-Jan-2019" "" "bst artifact pull Manual"
 | |
| 1 | +.TH "BST ARTIFACT PULL" "1" "12-Feb-2019" "" "bst artifact pull Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst\-artifact\-pull \- Pull a built artifact
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| 1 | -.TH "BST ARTIFACT PUSH" "1" "24-Jan-2019" "" "bst artifact push Manual"
 | |
| 1 | +.TH "BST ARTIFACT PUSH" "1" "12-Feb-2019" "" "bst artifact push Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst\-artifact\-push \- Push a built artifact
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| 1 | -.TH "BST-ARTIFACT-SERVER" "1" "24-Jan-2019" "" "bst-artifact-server Manual"
 | |
| 1 | +.TH "BST-ARTIFACT-SERVER" "1" "12-Feb-2019" "" "bst-artifact-server Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst-artifact-server \- CAS Artifact Server
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| 1 | -.TH "BST ARTIFACT" "1" "24-Jan-2019" "" "bst artifact Manual"
 | |
| 1 | +.TH "BST ARTIFACT" "1" "12-Feb-2019" "" "bst artifact Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst\-artifact \- Manipulate cached artifacts
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| 1 | -.TH "BST BUILD" "1" "24-Jan-2019" "" "bst build Manual"
 | |
| 1 | +.TH "BST BUILD" "1" "12-Feb-2019" "" "bst build Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst\-build \- Build elements in a pipeline
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| ... | ... | @@ -32,3 +32,6 @@ Allow tracking to cross junction boundaries | 
| 32 | 32 |  .TP
 | 
| 33 | 33 |  \fB\-\-track\-save\fP
 | 
| 34 | 34 |  Deprecated: This is ignored
 | 
| 35 | +.TP
 | |
| 36 | +\fB\-r,\fP \-\-remote TEXT
 | |
| 37 | +The URL of the remote cache (defaults to the first configured cache) | 
| 1 | -.TH "BST HELP" "1" "24-Jan-2019" "" "bst help Manual"
 | |
| 1 | +.TH "BST HELP" "1" "12-Feb-2019" "" "bst help Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst\-help \- Print usage information
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| 1 | -.TH "BST INIT" "1" "24-Jan-2019" "" "bst init Manual"
 | |
| 1 | +.TH "BST INIT" "1" "12-Feb-2019" "" "bst init Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst\-init \- Initialize a new BuildStream project
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| 1 | -.TH "BST SHELL" "1" "24-Jan-2019" "" "bst shell Manual"
 | |
| 1 | +.TH "BST SHELL" "1" "12-Feb-2019" "" "bst shell Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst\-shell \- Shell into an element's sandbox environment
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| 1 | -.TH "BST SHOW" "1" "24-Jan-2019" "" "bst show Manual"
 | |
| 1 | +.TH "BST SHOW" "1" "12-Feb-2019" "" "bst show Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst\-show \- Show elements in the pipeline
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| ... | ... | @@ -43,6 +43,9 @@ the following symbols can be used in the format string: | 
| 43 | 43 |      %{public}         Public domain data
 | 
| 44 | 44 |      %{workspaced}     If the element is workspaced
 | 
| 45 | 45 |      %{workspace-dirs} A list of workspace directories
 | 
| 46 | +    %{deps}           A list of all dependencies
 | |
| 47 | +    %{build-deps}     A list of build dependencies
 | |
| 48 | +    %{runtime-deps}   A list of runtime dependencies
 | |
| 46 | 49 |  .PP
 | 
| 47 | 50 |  The value of the %{symbol} without the leading '%' character is understood
 | 
| 48 | 51 |  as a pythonic formatting string, so python formatting features apply,
 | 
| 1 | -.TH "BST SOURCE CHECKOUT" "1" "24-Jan-2019" "" "bst source checkout Manual"
 | |
| 1 | +.TH "BST SOURCE CHECKOUT" "1" "12-Feb-2019" "" "bst source checkout Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst\-source\-checkout \- Checkout sources for an element
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| 1 | -.TH "BST SOURCE FETCH" "1" "24-Jan-2019" "" "bst source fetch Manual"
 | |
| 1 | +.TH "BST SOURCE FETCH" "1" "12-Feb-2019" "" "bst source fetch Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst\-source\-fetch \- Fetch sources in a pipeline
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| 1 | -.TH "BST SOURCE TRACK" "1" "24-Jan-2019" "" "bst source track Manual"
 | |
| 1 | +.TH "BST SOURCE TRACK" "1" "12-Feb-2019" "" "bst source track Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst\-source\-track \- Track new source references
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| 1 | -.TH "BST SOURCE" "1" "24-Jan-2019" "" "bst source Manual"
 | |
| 1 | +.TH "BST SOURCE" "1" "12-Feb-2019" "" "bst source Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst\-source \- Manipulate sources for an element
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| 1 | -.TH "BST WORKSPACE CLOSE" "1" "24-Jan-2019" "" "bst workspace close Manual"
 | |
| 1 | +.TH "BST WORKSPACE CLOSE" "1" "12-Feb-2019" "" "bst workspace close Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst\-workspace\-close \- Close workspaces
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| 1 | -.TH "BST WORKSPACE LIST" "1" "24-Jan-2019" "" "bst workspace list Manual"
 | |
| 1 | +.TH "BST WORKSPACE LIST" "1" "12-Feb-2019" "" "bst workspace list Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst\-workspace\-list \- List open workspaces
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| 1 | -.TH "BST WORKSPACE OPEN" "1" "24-Jan-2019" "" "bst workspace open Manual"
 | |
| 1 | +.TH "BST WORKSPACE OPEN" "1" "12-Feb-2019" "" "bst workspace open Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst\-workspace\-open \- Open a new workspace
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| 1 | -.TH "BST WORKSPACE RESET" "1" "24-Jan-2019" "" "bst workspace reset Manual"
 | |
| 1 | +.TH "BST WORKSPACE RESET" "1" "12-Feb-2019" "" "bst workspace reset Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst\-workspace\-reset \- Reset a workspace to its original state
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| 1 | -.TH "BST WORKSPACE" "1" "24-Jan-2019" "" "bst workspace Manual"
 | |
| 1 | +.TH "BST WORKSPACE" "1" "12-Feb-2019" "" "bst workspace Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst\-workspace \- Manipulate developer workspaces
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| 1 | -.TH "BST" "1" "24-Jan-2019" "" "bst Manual"
 | |
| 1 | +.TH "BST" "1" "12-Feb-2019" "" "bst Manual"
 | |
| 2 | 2 |  .SH NAME
 | 
| 3 | 3 |  bst \- Build and manipulate BuildStream projects...
 | 
| 4 | 4 |  .SH SYNOPSIS
 | 
| ... | ... | @@ -709,3 +709,114 @@ def test_build_checkout_cross_junction(datafiles, cli, tmpdir): | 
| 709 | 709 |  | 
| 710 | 710 |      filename = os.path.join(checkout, 'etc', 'animal.conf')
 | 
| 711 | 711 |      assert os.path.exists(filename)
 | 
| 712 | + | |
| 713 | + | |
| 714 | +@pytest.mark.datafiles(DATA_DIR)
 | |
| 715 | +def test_build_junction_short_notation(cli, tmpdir, datafiles):
 | |
| 716 | +    project = os.path.join(datafiles.dirname, datafiles.basename)
 | |
| 717 | +    subproject_path = os.path.join(project, 'files', 'sub-project')
 | |
| 718 | +    junction_path = os.path.join(project, 'elements', 'junction.bst')
 | |
| 719 | +    element_path = os.path.join(project, 'elements', 'junction-dep.bst')
 | |
| 720 | +    workspace = os.path.join(cli.directory, 'workspace')
 | |
| 721 | +    checkout = os.path.join(cli.directory, 'checkout')
 | |
| 722 | + | |
| 723 | +    # Create a repo to hold the subproject and generate a junction element for it
 | |
| 724 | +    ref = generate_junction(tmpdir, subproject_path, junction_path)
 | |
| 725 | + | |
| 726 | +    # Create a stack element to depend on a cross junction element, using
 | |
| 727 | +    # colon (:) as the separator
 | |
| 728 | +    element = {
 | |
| 729 | +        'kind': 'stack',
 | |
| 730 | +        'depends': ['junction.bst:import-etc.bst']
 | |
| 731 | +    }
 | |
| 732 | +    _yaml.dump(element, element_path)
 | |
| 733 | + | |
| 734 | +    # Now try to build it, this should automatically result in fetching
 | |
| 735 | +    # the junction itself at load time.
 | |
| 736 | +    result = cli.run(project=project, args=['build', 'junction-dep.bst'])
 | |
| 737 | +    result.assert_success()
 | |
| 738 | + | |
| 739 | +    # Assert that it's cached now
 | |
| 740 | +    assert cli.get_element_state(project, 'junction-dep.bst') == 'cached'
 | |
| 741 | + | |
| 742 | +    # Now check it out
 | |
| 743 | +    result = cli.run(project=project, args=[
 | |
| 744 | +        'artifact', 'checkout', 'junction-dep.bst', '--directory', checkout
 | |
| 745 | +    ])
 | |
| 746 | +    result.assert_success()
 | |
| 747 | + | |
| 748 | +    # Assert the content of /etc/animal.conf
 | |
| 749 | +    filename = os.path.join(checkout, 'etc', 'animal.conf')
 | |
| 750 | +    assert os.path.exists(filename)
 | |
| 751 | +    with open(filename, 'r') as f:
 | |
| 752 | +        contents = f.read()
 | |
| 753 | +    assert contents == 'animal=Pony\n'
 | |
| 754 | + | |
| 755 | + | |
| 756 | +@pytest.mark.datafiles(DATA_DIR)
 | |
| 757 | +def test_build_junction_short_notation_filename(cli, tmpdir, datafiles):
 | |
| 758 | +    project = os.path.join(datafiles.dirname, datafiles.basename)
 | |
| 759 | +    subproject_path = os.path.join(project, 'files', 'sub-project')
 | |
| 760 | +    junction_path = os.path.join(project, 'elements', 'junction.bst')
 | |
| 761 | +    element_path = os.path.join(project, 'elements', 'junction-dep.bst')
 | |
| 762 | +    checkout = os.path.join(cli.directory, 'checkout')
 | |
| 763 | + | |
| 764 | +    # Create a repo to hold the subproject and generate a junction element for it
 | |
| 765 | +    ref = generate_junction(tmpdir, subproject_path, junction_path)
 | |
| 766 | + | |
| 767 | +    # Create a stack element to depend on a cross junction element, using
 | |
| 768 | +    # colon (:) as the separator
 | |
| 769 | +    element = {
 | |
| 770 | +        'kind': 'stack',
 | |
| 771 | +        'depends': [{'filename': 'junction.bst:import-etc.bst'}]
 | |
| 772 | +    }
 | |
| 773 | +    _yaml.dump(element, element_path)
 | |
| 774 | + | |
| 775 | +    # Now try to build it, this should automatically result in fetching
 | |
| 776 | +    # the junction itself at load time.
 | |
| 777 | +    result = cli.run(project=project, args=['build', 'junction-dep.bst'])
 | |
| 778 | +    result.assert_success()
 | |
| 779 | + | |
| 780 | +    # Assert that it's cached now
 | |
| 781 | +    assert cli.get_element_state(project, 'junction-dep.bst') == 'cached'
 | |
| 782 | + | |
| 783 | +    # Now check it out
 | |
| 784 | +    result = cli.run(project=project, args=[
 | |
| 785 | +        'artifact', 'checkout', 'junction-dep.bst', '--directory', checkout
 | |
| 786 | +    ])
 | |
| 787 | +    result.assert_success()
 | |
| 788 | + | |
| 789 | +    # Assert the content of /etc/animal.conf
 | |
| 790 | +    filename = os.path.join(checkout, 'etc', 'animal.conf')
 | |
| 791 | +    assert os.path.exists(filename)
 | |
| 792 | +    with open(filename, 'r') as f:
 | |
| 793 | +        contents = f.read()
 | |
| 794 | +    assert contents == 'animal=Pony\n'
 | |
| 795 | + | |
| 796 | + | |
| 797 | +@pytest.mark.datafiles(DATA_DIR)
 | |
| 798 | +def test_build_junction_short_notation_no_recurse(cli, tmpdir, datafiles):
 | |
| 799 | +    project = os.path.join(datafiles.dirname, datafiles.basename)
 | |
| 800 | +    subproject_path = os.path.join(project, 'files', 'sub-project')
 | |
| 801 | +    junction_path = os.path.join(project, 'elements', 'junction.bst')
 | |
| 802 | +    element_path = os.path.join(project, 'elements', 'junction-dep.bst')
 | |
| 803 | +    checkout = os.path.join(cli.directory, 'checkout')
 | |
| 804 | + | |
| 805 | +    # Create a repo to hold the subproject and generate a junction element for it
 | |
| 806 | +    ref = generate_junction(tmpdir, subproject_path, junction_path)
 | |
| 807 | + | |
| 808 | +    # Create a stack element to depend on a cross junction element, using
 | |
| 809 | +    # colon (:) as the separator
 | |
| 810 | +    element = {
 | |
| 811 | +        'kind': 'stack',
 | |
| 812 | +        'depends': [{
 | |
| 813 | +            'filename': 'junction.bst:import-etc.bst',
 | |
| 814 | +            'junction': 'junction.bst',
 | |
| 815 | +        }]
 | |
| 816 | +    }
 | |
| 817 | +    _yaml.dump(element, element_path)
 | |
| 818 | + | |
| 819 | +    # Now try to build it, this should fail as recursive lookups for
 | |
| 820 | +    # cross-junction elements is not allowed.
 | |
| 821 | +    result = cli.run(project=project, args=['build', 'junction-dep.bst'])
 | |
| 822 | +    result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA) | 
| ... | ... | @@ -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)) | 
