summaryrefslogtreecommitdiff
path: root/tests/loader/dependencies.py
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2016-12-06 10:54:55 +0100
committerJürg Billeter <j@bitron.ch>2016-12-12 10:58:47 +0100
commit24523b1569896cd48d384d1b9d515c461dba767d (patch)
tree27c0c653182433f00ecb704cab6eaa743c53392c /tests/loader/dependencies.py
parent5804a503cbd02bd794cde2b82f014d96a04effde (diff)
downloadbuildstream-24523b1569896cd48d384d1b9d515c461dba767d.tar.gz
Add loader tests for dependency types
Diffstat (limited to 'tests/loader/dependencies.py')
-rw-r--r--tests/loader/dependencies.py60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/loader/dependencies.py b/tests/loader/dependencies.py
index e301e6057..8a88bcaf8 100644
--- a/tests/loader/dependencies.py
+++ b/tests/loader/dependencies.py
@@ -109,3 +109,63 @@ def test_circular_dependency(datafiles):
element = loader.load()
assert (exc.value.reason == LoadErrorReason.CIRCULAR_DEPENDENCY)
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_invalid_dependency_type(datafiles):
+ basedir = os.path.join(datafiles.dirname, datafiles.basename)
+ loader = Loader(basedir, 'elements/invaliddeptype.bst', None, None)
+
+ with pytest.raises(LoadError) as exc:
+ element = loader.load()
+
+ assert (exc.value.reason == LoadErrorReason.INVALID_DATA)
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_build_dependency(datafiles):
+ basedir = os.path.join(datafiles.dirname, datafiles.basename)
+ loader = Loader(basedir, 'elements/builddep.bst', None, None)
+ element = loader.load()
+
+ assert(isinstance(element, MetaElement))
+ assert(element.kind == 'pony')
+
+ assert(len(element.build_dependencies) == 1)
+ firstdep = element.build_dependencies[0]
+ assert(isinstance(firstdep, MetaElement))
+
+ assert(len(element.dependencies) == 0)
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_runtime_dependency(datafiles):
+ basedir = os.path.join(datafiles.dirname, datafiles.basename)
+ loader = Loader(basedir, 'elements/runtimedep.bst', None, None)
+ element = loader.load()
+
+ assert(isinstance(element, MetaElement))
+ assert(element.kind == 'pony')
+
+ assert(len(element.dependencies) == 1)
+ firstdep = element.dependencies[0]
+ assert(isinstance(firstdep, MetaElement))
+
+ assert(len(element.build_dependencies) == 0)
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_build_runtime_dependency(datafiles):
+ basedir = os.path.join(datafiles.dirname, datafiles.basename)
+ loader = Loader(basedir, 'elements/target.bst', None, None)
+ element = loader.load()
+
+ assert(isinstance(element, MetaElement))
+ assert(element.kind == 'pony')
+
+ assert(len(element.dependencies) == 1)
+ assert(len(element.build_dependencies) == 1)
+ firstdep = element.dependencies[0]
+ assert(isinstance(firstdep, MetaElement))
+ firstbuilddep = element.build_dependencies[0]
+ assert(firstdep == firstbuilddep)