diff options
author | Chandan Singh <csingh43@bloomberg.net> | 2018-09-26 00:30:17 +0100 |
---|---|---|
committer | Benjamin Schubert <ben.c.schubert@gmail.com> | 2018-11-12 10:33:59 +0000 |
commit | f03ed2d6158b4753b3e7293fd9c782c209b6277e (patch) | |
tree | 840014dc3748bdbca0143d521277215e9a10b5a9 | |
parent | dd5e7b04fc1f333c0bfa577f4d30bb26b945e055 (diff) | |
download | buildstream-f03ed2d6158b4753b3e7293fd9c782c209b6277e.tar.gz |
Ensure `--deps=none` option works for `bst checkout`
Currently, `bst checkout --deps none` command always produces empty
output. Fix this issue and add regression test for the same.
- element_enums.py: Add Scope.NONE.
- element.py: Ensure Scope.NONE works correctly in addition to
Scope.RUN/Scope.ALL in Element.dependencies() and Element.search().
- tests/frontend/buildcheckout.py: Fix tests for `--deps none`.
Fixes #670.
-rw-r--r-- | buildstream/element.py | 26 | ||||
-rw-r--r-- | buildstream/types.py | 6 | ||||
-rw-r--r-- | tests/frontend/buildcheckout.py | 20 | ||||
-rw-r--r-- | tests/frontend/project/elements/checkout-deps.bst | 10 | ||||
-rw-r--r-- | tests/frontend/project/files/etc-files/etc/buildstream/config | 1 |
5 files changed, 40 insertions, 23 deletions
diff --git a/buildstream/element.py b/buildstream/element.py index 31ca5d307..91ce177c6 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -432,7 +432,7 @@ class Element(Plugin): visited=visited, recursed=True) # Yeild self only at the end, after anything needed has been traversed - if should_yield and (recurse or recursed) and (scope in (Scope.ALL, Scope.RUN)): + if should_yield and (recurse or recursed) and scope != Scope.BUILD: yield self def search(self, scope, name): @@ -1329,17 +1329,21 @@ class Element(Plugin): if scope == Scope.BUILD: self.stage(sandbox) elif scope == Scope.RUN: - # Stage deps in the sandbox root if deps == 'run': - with self.timed_activity("Staging dependencies", silent_nested=True): - self.stage_dependency_artifacts(sandbox, scope) - - # Run any integration commands provided by the dependencies - # once they are all staged and ready - if integrate: - with self.timed_activity("Integrating sandbox"): - for dep in self.dependencies(scope): - dep.integrate(sandbox) + dependency_scope = Scope.RUN + else: + dependency_scope = Scope.NONE + + # Stage deps in the sandbox root + with self.timed_activity("Staging dependencies", silent_nested=True): + self.stage_dependency_artifacts(sandbox, dependency_scope) + + # Run any integration commands provided by the dependencies + # once they are all staged and ready + if integrate: + with self.timed_activity("Integrating sandbox"): + for dep in self.dependencies(dependency_scope): + dep.integrate(sandbox) yield sandbox diff --git a/buildstream/types.py b/buildstream/types.py index 7bc7a1664..3eb4a9110 100644 --- a/buildstream/types.py +++ b/buildstream/types.py @@ -48,6 +48,12 @@ class Scope(Enum): itself. """ + NONE = 4 + """Just the element itself, no dependencies. + + *Since: 1.4* + """ + class Consistency(): """Defines the various consistency states of a :class:`.Source`. diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py index a0b461762..480eeadf9 100644 --- a/tests/frontend/buildcheckout.py +++ b/tests/frontend/buildcheckout.py @@ -65,9 +65,10 @@ def test_build_checkout(datafiles, cli, strict, hardlinks): def test_build_checkout_deps(datafiles, cli, deps): project = os.path.join(datafiles.dirname, datafiles.basename) checkout = os.path.join(cli.directory, 'checkout') + element_name = "checkout-deps.bst" # First build it - result = cli.run(project=project, args=['build', 'target.bst']) + result = cli.run(project=project, args=['build', element_name]) result.assert_success() # Assert that after a successful build, the builddir is empty @@ -76,20 +77,15 @@ def test_build_checkout_deps(datafiles, cli, deps): assert not os.listdir(builddir) # Now check it out - result = cli.run(project=project, args=['checkout', 'target.bst', '--deps', deps, checkout]) + result = cli.run(project=project, args=['checkout', element_name, '--deps', deps, checkout]) result.assert_success() - # Check that the executable hello file is found in the checkout - filename = os.path.join(checkout, 'usr', 'bin', 'hello') - - if deps == "run": - assert os.path.exists(filename) - else: - assert not os.path.exists(filename) - - # Check that the executable hello file is found in the checkout - filename = os.path.join(checkout, 'usr', 'include', 'pony.h') + # Verify output of this element + filename = os.path.join(checkout, 'etc', 'buildstream', 'config') + assert os.path.exists(filename) + # Verify output of this element's runtime dependencies + filename = os.path.join(checkout, 'usr', 'bin', 'hello') if deps == "run": assert os.path.exists(filename) else: diff --git a/tests/frontend/project/elements/checkout-deps.bst b/tests/frontend/project/elements/checkout-deps.bst new file mode 100644 index 000000000..a2c1d93cc --- /dev/null +++ b/tests/frontend/project/elements/checkout-deps.bst @@ -0,0 +1,10 @@ +kind: import +description: It is important for this element to have both build and runtime dependencies +sources: +- kind: local + path: files/etc-files +depends: +- filename: import-dev.bst + type: build +- filename: import-bin.bst + type: runtime diff --git a/tests/frontend/project/files/etc-files/etc/buildstream/config b/tests/frontend/project/files/etc-files/etc/buildstream/config new file mode 100644 index 000000000..04204c7c9 --- /dev/null +++ b/tests/frontend/project/files/etc-files/etc/buildstream/config @@ -0,0 +1 @@ +config |