summaryrefslogtreecommitdiff
path: root/tests/loader
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-10-04 17:39:07 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-10-10 19:29:59 +0900
commitfa512fef4765cc63ceeb4a901a3a517cb83606d6 (patch)
tree3585e1bf833e962e15e964ef9cec78d6a17c4c49 /tests/loader
parentce5a47973bb639c1f61cd65cce212bb0308f0134 (diff)
downloadbuildstream-fa512fef4765cc63ceeb4a901a3a517cb83606d6.tar.gz
Updated test cases for internal API changes stemming from project options
Diffstat (limited to 'tests/loader')
-rw-r--r--tests/loader/__init__.py12
-rw-r--r--tests/loader/arches.py13
-rw-r--r--tests/loader/basics.py13
-rw-r--r--tests/loader/dependencies.py21
4 files changed, 37 insertions, 22 deletions
diff --git a/tests/loader/__init__.py b/tests/loader/__init__.py
index e69de29bb..3cd5c3ec9 100644
--- a/tests/loader/__init__.py
+++ b/tests/loader/__init__.py
@@ -0,0 +1,12 @@
+from buildstream._options import OptionPool
+
+
+#
+# This is used by the loader test modules, these should
+# be removed in favor of testing the functionality via
+# the CLI like in the frontend tests anyway.
+#
+def make_options(basedir):
+ options = OptionPool(basedir)
+ options.resolve()
+ return options
diff --git a/tests/loader/arches.py b/tests/loader/arches.py
index 041fbb7e1..4106aec54 100644
--- a/tests/loader/arches.py
+++ b/tests/loader/arches.py
@@ -4,6 +4,7 @@ import pytest
from buildstream import LoadError, LoadErrorReason
from buildstream._loader import Loader
from buildstream._metaelement import MetaElement
+from . import make_options
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
@@ -19,7 +20,7 @@ def test_simple_conditional_nomatch(datafiles):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
loader = Loader(
- basedir, 'elements/simple-conditional.bst', 'arm', None)
+ basedir, 'elements/simple-conditional.bst', make_options(basedir), 'arm', None)
element = loader.load()
assert(isinstance(element, MetaElement))
@@ -34,7 +35,7 @@ def test_simple_conditional_x86_64(datafiles):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
loader = Loader(
- basedir, 'elements/simple-conditional.bst', 'x86_64', None)
+ basedir, 'elements/simple-conditional.bst', make_options(basedir), 'x86_64', None)
element = loader.load()
assert(isinstance(element, MetaElement))
@@ -49,7 +50,7 @@ def test_simple_conditional_x86_32(datafiles):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
loader = Loader(
- basedir, 'elements/simple-conditional.bst', 'x86_32', None)
+ basedir, 'elements/simple-conditional.bst', make_options(basedir), 'x86_32', None)
element = loader.load()
assert(isinstance(element, MetaElement))
@@ -69,7 +70,7 @@ def test_host_arch_conditional_armv8(datafiles):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
loader = Loader(
- basedir, 'elements/host-arch-conditional.bst', 'armv8', None)
+ basedir, 'elements/host-arch-conditional.bst', make_options(basedir), 'armv8', None)
element = loader.load()
assert(isinstance(element, MetaElement))
@@ -84,7 +85,7 @@ def test_host_arch_conditional_ignores_target_arch(datafiles):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
loader = Loader(
- basedir, 'elements/host-arch-conditional.bst', 'armv8', 'x86_32')
+ basedir, 'elements/host-arch-conditional.bst', make_options(basedir), 'armv8', 'x86_32')
element = loader.load()
assert(isinstance(element, MetaElement))
@@ -100,7 +101,7 @@ def test_host_arch_conditional_overridden(datafiles):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
loader = Loader(
- basedir, 'elements/host-arch-conditional.bst', 'armv8', 'x86_64')
+ basedir, 'elements/host-arch-conditional.bst', make_options(basedir), 'armv8', 'x86_64')
element = loader.load()
assert(isinstance(element, MetaElement))
diff --git a/tests/loader/basics.py b/tests/loader/basics.py
index a395d3768..c85477898 100644
--- a/tests/loader/basics.py
+++ b/tests/loader/basics.py
@@ -4,6 +4,7 @@ import pytest
from buildstream import LoadError, LoadErrorReason
from buildstream._loader import Loader
from buildstream._metaelement import MetaElement
+from . import make_options
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
@@ -18,7 +19,7 @@ DATA_DIR = os.path.join(
def test_one_file(datafiles):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
- loader = Loader(basedir, 'elements/onefile.bst', None, None)
+ loader = Loader(basedir, 'elements/onefile.bst', make_options(basedir), None, None)
element = loader.load()
@@ -30,7 +31,7 @@ def test_one_file(datafiles):
def test_missing_file(datafiles):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
- loader = Loader(basedir, 'elements/missing.bst', None, None)
+ loader = Loader(basedir, 'elements/missing.bst', make_options(basedir), None, None)
with pytest.raises(LoadError) as exc:
element = loader.load()
@@ -42,7 +43,7 @@ def test_missing_file(datafiles):
def test_invalid_reference(datafiles):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
- loader = Loader(basedir, 'elements/badreference.bst', None, None)
+ loader = Loader(basedir, 'elements/badreference.bst', make_options(basedir), None, None)
with pytest.raises(LoadError) as exc:
element = loader.load()
@@ -54,7 +55,7 @@ def test_invalid_reference(datafiles):
def test_invalid_yaml(datafiles):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
- loader = Loader(basedir, 'elements/badfile.bst', None, None)
+ loader = Loader(basedir, 'elements/badfile.bst', make_options(basedir), None, None)
with pytest.raises(LoadError) as exc:
element = loader.load()
@@ -69,7 +70,7 @@ def test_fail_fullpath_target(datafiles):
fullpath = os.path.join(basedir, 'elements', 'onefile.bst')
with pytest.raises(LoadError) as exc:
- loader = Loader(basedir, fullpath, None, None)
+ loader = Loader(basedir, fullpath, make_options(basedir), None, None)
assert (exc.value.reason == LoadErrorReason.INVALID_DATA)
@@ -78,7 +79,7 @@ def test_fail_fullpath_target(datafiles):
def test_invalid_key(datafiles):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
- loader = Loader(basedir, 'elements/invalidkey.bst', None, None)
+ loader = Loader(basedir, 'elements/invalidkey.bst', make_options(basedir), None, None)
with pytest.raises(LoadError) as exc:
element = loader.load()
diff --git a/tests/loader/dependencies.py b/tests/loader/dependencies.py
index 3850a0086..3a4fee278 100644
--- a/tests/loader/dependencies.py
+++ b/tests/loader/dependencies.py
@@ -4,6 +4,7 @@ import pytest
from buildstream import LoadError, LoadErrorReason
from buildstream._loader import Loader
from buildstream._metaelement import MetaElement
+from . import make_options
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
@@ -18,7 +19,7 @@ DATA_DIR = os.path.join(
def test_two_files(datafiles):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
- loader = Loader(basedir, 'elements/target.bst', None, None)
+ loader = Loader(basedir, 'elements/target.bst', make_options(basedir), None, None)
element = loader.load()
assert(isinstance(element, MetaElement))
@@ -34,7 +35,7 @@ def test_two_files(datafiles):
def test_shared_dependency(datafiles):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
- loader = Loader(basedir, 'elements/shareddeptarget.bst', None, None)
+ loader = Loader(basedir, 'elements/shareddeptarget.bst', make_options(basedir), None, None)
element = loader.load()
# Toplevel is 'pony' with 2 dependencies
@@ -77,7 +78,7 @@ def test_shared_dependency(datafiles):
def test_dependency_dict(datafiles):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
- loader = Loader(basedir, 'elements/target-depdict.bst', None, None)
+ loader = Loader(basedir, 'elements/target-depdict.bst', make_options(basedir), None, None)
element = loader.load()
assert(isinstance(element, MetaElement))
@@ -92,7 +93,7 @@ def test_dependency_dict(datafiles):
@pytest.mark.datafiles(DATA_DIR)
def test_invalid_dependency_declaration(datafiles):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
- loader = Loader(basedir, 'elements/invaliddep.bst', None, None)
+ loader = Loader(basedir, 'elements/invaliddep.bst', make_options(basedir), None, None)
with pytest.raises(LoadError) as exc:
element = loader.load()
@@ -103,7 +104,7 @@ def test_invalid_dependency_declaration(datafiles):
@pytest.mark.datafiles(DATA_DIR)
def test_circular_dependency(datafiles):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
- loader = Loader(basedir, 'elements/circulartarget.bst', None, None)
+ loader = Loader(basedir, 'elements/circulartarget.bst', make_options(basedir), None, None)
with pytest.raises(LoadError) as exc:
element = loader.load()
@@ -114,7 +115,7 @@ def test_circular_dependency(datafiles):
@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)
+ loader = Loader(basedir, 'elements/invaliddeptype.bst', make_options(basedir), None, None)
with pytest.raises(LoadError) as exc:
element = loader.load()
@@ -125,7 +126,7 @@ def test_invalid_dependency_type(datafiles):
@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)
+ loader = Loader(basedir, 'elements/builddep.bst', make_options(basedir), None, None)
element = loader.load()
assert(isinstance(element, MetaElement))
@@ -141,7 +142,7 @@ def test_build_dependency(datafiles):
@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)
+ loader = Loader(basedir, 'elements/runtimedep.bst', make_options(basedir), None, None)
element = loader.load()
assert(isinstance(element, MetaElement))
@@ -157,7 +158,7 @@ def test_runtime_dependency(datafiles):
@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)
+ loader = Loader(basedir, 'elements/target.bst', make_options(basedir), None, None)
element = loader.load()
assert(isinstance(element, MetaElement))
@@ -174,7 +175,7 @@ def test_build_runtime_dependency(datafiles):
@pytest.mark.datafiles(DATA_DIR)
def test_all_dependency(datafiles):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
- loader = Loader(basedir, 'elements/alldep.bst', None, None)
+ loader = Loader(basedir, 'elements/alldep.bst', make_options(basedir), None, None)
element = loader.load()
assert(isinstance(element, MetaElement))