This is an automated email from the ASF dual-hosted git repository. github-bot pushed a commit to branch 463-make-dependency-type-default-to-build in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 80b174fe48a85ab21732f93c854b8c9632c43978 Author: Jonathan Maw <[email protected]> AuthorDate: Thu Aug 9 17:57:51 2018 +0100 tests: Add tests for loading builddeps and runtime deps --- tests/loader/dependencies.py | 53 ++++++++++++++++++++-- .../loader/dependencies/elements/builddep-list.bst | 4 ++ tests/loader/dependencies/elements/firstdep.bst | 2 +- .../loader/dependencies/elements/list-combine.bst | 8 ++++ .../loader/dependencies/elements/list-overlap.bst | 7 +++ .../dependencies/elements/runtimedep-list.bst | 4 ++ tests/loader/dependencies/elements/seconddep.bst | 2 + tests/loader/dependencies/elements/thirddep.bst | 2 + 8 files changed, 78 insertions(+), 4 deletions(-) diff --git a/tests/loader/dependencies.py b/tests/loader/dependencies.py index 4bb13a3..cb750fc 100644 --- a/tests/loader/dependencies.py +++ b/tests/loader/dependencies.py @@ -3,6 +3,7 @@ import pytest from buildstream._exceptions import LoadError, LoadErrorReason from buildstream._loader import Loader, MetaElement +from tests.testutils import cli from . import make_loader DATA_DIR = os.path.join( @@ -27,7 +28,7 @@ def test_two_files(datafiles): assert(len(element.dependencies) == 1) firstdep = element.dependencies[0] assert(isinstance(firstdep, MetaElement)) - assert(firstdep.kind == 'thefirstdep') + assert(firstdep.kind == 'manual') @pytest.mark.datafiles(DATA_DIR) @@ -47,7 +48,7 @@ def test_shared_dependency(datafiles): # firstdep = element.dependencies[0] assert(isinstance(firstdep, MetaElement)) - assert(firstdep.kind == 'thefirstdep') + assert(firstdep.kind == 'manual') assert(len(firstdep.dependencies) == 0) # The second specified dependency is 'shareddep' @@ -86,7 +87,7 @@ def test_dependency_dict(datafiles): assert(len(element.dependencies) == 1) firstdep = element.dependencies[0] assert(isinstance(firstdep, MetaElement)) - assert(firstdep.kind == 'thefirstdep') + assert(firstdep.kind == 'manual') @pytest.mark.datafiles(DATA_DIR) @@ -186,3 +187,49 @@ def test_all_dependency(datafiles): assert(isinstance(firstdep, MetaElement)) firstbuilddep = element.build_dependencies[0] assert(firstdep == firstbuilddep) + + [email protected](DATA_DIR) +def test_list_build_dependency(cli, datafiles): + project = str(datafiles) + + # Check that the pipeline includes the build dependency + deps = cli.get_pipeline(project, ['elements/builddep-list.bst'], scope="build") + assert "elements/firstdep.bst" in deps + + [email protected](DATA_DIR) +def test_list_runtime_dependency(cli, datafiles): + project = str(datafiles) + + # Check that the pipeline includes the runtime dependency + deps = cli.get_pipeline(project, ['elements/runtimedep-list.bst'], scope="run") + assert "elements/firstdep.bst" in deps + + [email protected](DATA_DIR) +def test_list_dependencies_combined(cli, datafiles): + project = str(datafiles) + + # Check that runtime deps get combined + rundeps = cli.get_pipeline(project, ['elements/list-combine.bst'], scope="run") + assert "elements/firstdep.bst" not in rundeps + assert "elements/seconddep.bst" in rundeps + assert "elements/thirddep.bst" in rundeps + + # Check that build deps get combined + builddeps = cli.get_pipeline(project, ['elements/list-combine.bst'], scope="build") + assert "elements/firstdep.bst" in builddeps + assert "elements/seconddep.bst" not in builddeps + assert "elements/thirddep.bst" in builddeps + + [email protected](DATA_DIR) +def test_list_overlap(cli, datafiles): + project = str(datafiles) + + # Check that dependencies get merged + rundeps = cli.get_pipeline(project, ['elements/list-overlap.bst'], scope="run") + assert "elements/firstdep.bst" in rundeps + builddeps = cli.get_pipeline(project, ['elements/list-overlap.bst'], scope="build") + assert "elements/firstdep.bst" in builddeps diff --git a/tests/loader/dependencies/elements/builddep-list.bst b/tests/loader/dependencies/elements/builddep-list.bst new file mode 100644 index 0000000..925de3a --- /dev/null +++ b/tests/loader/dependencies/elements/builddep-list.bst @@ -0,0 +1,4 @@ +kind: stack +description: This element has a build-only dependency specified via build-depends +build-depends: + - elements/firstdep.bst diff --git a/tests/loader/dependencies/elements/firstdep.bst b/tests/loader/dependencies/elements/firstdep.bst index 9b6a578..5c9c1c1 100644 --- a/tests/loader/dependencies/elements/firstdep.bst +++ b/tests/loader/dependencies/elements/firstdep.bst @@ -1,2 +1,2 @@ -kind: thefirstdep +kind: manual description: This is the first dependency diff --git a/tests/loader/dependencies/elements/list-combine.bst b/tests/loader/dependencies/elements/list-combine.bst new file mode 100644 index 0000000..2010d70 --- /dev/null +++ b/tests/loader/dependencies/elements/list-combine.bst @@ -0,0 +1,8 @@ +kind: stack +description: This element depends on three elements in different ways +build-depends: +- elements/firstdep.bst +runtime-depends: +- elements/seconddep.bst +depends: +- elements/thirddep.bst diff --git a/tests/loader/dependencies/elements/list-overlap.bst b/tests/loader/dependencies/elements/list-overlap.bst new file mode 100644 index 0000000..1e98a20 --- /dev/null +++ b/tests/loader/dependencies/elements/list-overlap.bst @@ -0,0 +1,7 @@ +kind: stack +description: This element depends on two elements in different ways +build-depends: +- elements/firstdep.bst +depends: +- filename: elements/firstdep.bst + type: runtime diff --git a/tests/loader/dependencies/elements/runtimedep-list.bst b/tests/loader/dependencies/elements/runtimedep-list.bst new file mode 100644 index 0000000..790fa4d --- /dev/null +++ b/tests/loader/dependencies/elements/runtimedep-list.bst @@ -0,0 +1,4 @@ +kind: stack +description: This element has a runtime-only dependency +runtime-depends: + - elements/firstdep.bst diff --git a/tests/loader/dependencies/elements/seconddep.bst b/tests/loader/dependencies/elements/seconddep.bst new file mode 100644 index 0000000..93ded43 --- /dev/null +++ b/tests/loader/dependencies/elements/seconddep.bst @@ -0,0 +1,2 @@ +kind: manual +description: This is the second dependency diff --git a/tests/loader/dependencies/elements/thirddep.bst b/tests/loader/dependencies/elements/thirddep.bst new file mode 100644 index 0000000..39b58e5 --- /dev/null +++ b/tests/loader/dependencies/elements/thirddep.bst @@ -0,0 +1,2 @@ +kind: manual +description: This is the third dependency
