diff options
author | Jonathan Maw <jonathan.maw@codethink.co.uk> | 2018-08-09 17:57:51 +0100 |
---|---|---|
committer | Jonathan Maw <jonathan.maw@codethink.co.uk> | 2018-08-14 09:54:31 +0100 |
commit | 95798475a24ffdd3ee78d799faa23e6c7f0a0370 (patch) | |
tree | fa9c7977bd12410dd6dc1833c0ba69e0ef446a45 | |
parent | 0c8d0b0b2f6d70151c698262e794b46e818e52e1 (diff) | |
download | buildstream-95798475a24ffdd3ee78d799faa23e6c7f0a0370.tar.gz |
tests: Add tests for loading builddeps and runtime deps
-rw-r--r-- | tests/loader/dependencies.py | 53 | ||||
-rw-r--r-- | tests/loader/dependencies/elements/builddep-list.bst | 4 | ||||
-rw-r--r-- | tests/loader/dependencies/elements/firstdep.bst | 2 | ||||
-rw-r--r-- | tests/loader/dependencies/elements/list-combine.bst | 8 | ||||
-rw-r--r-- | tests/loader/dependencies/elements/list-overlap.bst | 7 | ||||
-rw-r--r-- | tests/loader/dependencies/elements/runtimedep-list.bst | 4 | ||||
-rw-r--r-- | tests/loader/dependencies/elements/seconddep.bst | 2 | ||||
-rw-r--r-- | 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 4bb13a380..cb750fcb1 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) + + +@pytest.mark.datafiles(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 + + +@pytest.mark.datafiles(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 + + +@pytest.mark.datafiles(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 + + +@pytest.mark.datafiles(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 000000000..925de3afd --- /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 9b6a57824..5c9c1c1e6 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 000000000..2010d7008 --- /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 000000000..1e98a20a5 --- /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 000000000..790fa4d54 --- /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 000000000..93ded4359 --- /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 000000000..39b58e57a --- /dev/null +++ b/tests/loader/dependencies/elements/thirddep.bst @@ -0,0 +1,2 @@ +kind: manual +description: This is the third dependency |