diff options
Diffstat (limited to 'tests/loader')
-rw-r--r-- | tests/loader/__init__.py | 4 | ||||
-rw-r--r-- | tests/loader/basics.py | 27 | ||||
-rw-r--r-- | tests/loader/dependencies.py | 40 |
3 files changed, 36 insertions, 35 deletions
diff --git a/tests/loader/__init__.py b/tests/loader/__init__.py index d64b776a4..49db9cfd0 100644 --- a/tests/loader/__init__.py +++ b/tests/loader/__init__.py @@ -8,7 +8,7 @@ from buildstream._loader import Loader # be removed in favor of testing the functionality via # the CLI like in the frontend tests anyway. # -def make_loader(basedir, targets): +def make_loader(basedir): context = Context() project = Project(basedir, context) - return Loader(context, project, targets) + return Loader(context, project) diff --git a/tests/loader/basics.py b/tests/loader/basics.py index 3526697c5..d7fc28f83 100644 --- a/tests/loader/basics.py +++ b/tests/loader/basics.py @@ -18,9 +18,9 @@ DATA_DIR = os.path.join( def test_one_file(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = make_loader(basedir, ['elements/onefile.bst']) + loader = make_loader(basedir) - element = loader.load()[0] + element = loader.load(['elements/onefile.bst'])[0] assert(isinstance(element, MetaElement)) assert(element.kind == 'pony') @@ -30,10 +30,10 @@ def test_one_file(datafiles): def test_missing_file(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = make_loader(basedir, ['elements/missing.bst']) + loader = make_loader(basedir) with pytest.raises(LoadError) as exc: - element = loader.load()[0] + element = loader.load(['elements/missing.bst'])[0] assert (exc.value.reason == LoadErrorReason.MISSING_FILE) @@ -42,10 +42,10 @@ def test_missing_file(datafiles): def test_invalid_reference(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = make_loader(basedir, ['elements/badreference.bst']) + loader = make_loader(basedir) with pytest.raises(LoadError) as exc: - element = loader.load()[0] + element = loader.load(['elements/badreference.bst'])[0] assert (exc.value.reason == LoadErrorReason.INVALID_YAML) @@ -54,10 +54,10 @@ def test_invalid_reference(datafiles): def test_invalid_yaml(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = make_loader(basedir, ['elements/badfile.bst']) + loader = make_loader(basedir) with pytest.raises(LoadError) as exc: - element = loader.load()[0] + element = loader.load(['elements/badfile.bst'])[0] assert (exc.value.reason == LoadErrorReason.INVALID_YAML) @@ -69,7 +69,8 @@ def test_fail_fullpath_target(datafiles): fullpath = os.path.join(basedir, 'elements', 'onefile.bst') with pytest.raises(LoadError) as exc: - loader = make_loader(basedir, [fullpath]) + loader = make_loader(basedir) + loader.load([fullpath]) assert (exc.value.reason == LoadErrorReason.INVALID_DATA) @@ -78,10 +79,10 @@ def test_fail_fullpath_target(datafiles): def test_invalid_key(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = make_loader(basedir, ['elements/invalidkey.bst']) + loader = make_loader(basedir) with pytest.raises(LoadError) as exc: - element = loader.load()[0] + element = loader.load(['elements/invalidkey.bst'])[0] assert (exc.value.reason == LoadErrorReason.INVALID_DATA) @@ -90,9 +91,9 @@ def test_invalid_key(datafiles): def test_invalid_directory_load(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = make_loader(basedir, ['elements/']) + loader = make_loader(basedir) with pytest.raises(LoadError) as exc: - element = loader.load()[0] + element = loader.load(['elements/'])[0] assert (exc.value.reason == LoadErrorReason.LOADING_DIRECTORY) diff --git a/tests/loader/dependencies.py b/tests/loader/dependencies.py index 0816e3cfb..4bb13a380 100644 --- a/tests/loader/dependencies.py +++ b/tests/loader/dependencies.py @@ -18,8 +18,8 @@ DATA_DIR = os.path.join( def test_two_files(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = make_loader(basedir, ['elements/target.bst']) - element = loader.load()[0] + loader = make_loader(basedir) + element = loader.load(['elements/target.bst'])[0] assert(isinstance(element, MetaElement)) assert(element.kind == 'pony') @@ -34,8 +34,8 @@ def test_two_files(datafiles): def test_shared_dependency(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = make_loader(basedir, ['elements/shareddeptarget.bst']) - element = loader.load()[0] + loader = make_loader(basedir) + element = loader.load(['elements/shareddeptarget.bst'])[0] # Toplevel is 'pony' with 2 dependencies # @@ -77,8 +77,8 @@ def test_shared_dependency(datafiles): def test_dependency_dict(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = make_loader(basedir, ['elements/target-depdict.bst']) - element = loader.load()[0] + loader = make_loader(basedir) + element = loader.load(['elements/target-depdict.bst'])[0] assert(isinstance(element, MetaElement)) assert(element.kind == 'pony') @@ -92,10 +92,10 @@ 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 = make_loader(basedir, ['elements/invaliddep.bst']) + loader = make_loader(basedir) with pytest.raises(LoadError) as exc: - element = loader.load()[0] + element = loader.load(['elements/invaliddep.bst'])[0] assert (exc.value.reason == LoadErrorReason.INVALID_DATA) @@ -103,10 +103,10 @@ 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 = make_loader(basedir, ['elements/circulartarget.bst']) + loader = make_loader(basedir) with pytest.raises(LoadError) as exc: - element = loader.load()[0] + element = loader.load(['elements/circulartarget.bst'])[0] assert (exc.value.reason == LoadErrorReason.CIRCULAR_DEPENDENCY) @@ -114,10 +114,10 @@ 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 = make_loader(basedir, ['elements/invaliddeptype.bst']) + loader = make_loader(basedir) with pytest.raises(LoadError) as exc: - element = loader.load()[0] + element = loader.load(['elements/invaliddeptype.bst'])[0] assert (exc.value.reason == LoadErrorReason.INVALID_DATA) @@ -125,8 +125,8 @@ 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 = make_loader(basedir, ['elements/builddep.bst']) - element = loader.load()[0] + loader = make_loader(basedir) + element = loader.load(['elements/builddep.bst'])[0] assert(isinstance(element, MetaElement)) assert(element.kind == 'pony') @@ -141,8 +141,8 @@ def test_build_dependency(datafiles): @pytest.mark.datafiles(DATA_DIR) def test_runtime_dependency(datafiles): basedir = os.path.join(datafiles.dirname, datafiles.basename) - loader = make_loader(basedir, ['elements/runtimedep.bst']) - element = loader.load()[0] + loader = make_loader(basedir) + element = loader.load(['elements/runtimedep.bst'])[0] assert(isinstance(element, MetaElement)) assert(element.kind == 'pony') @@ -157,8 +157,8 @@ 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 = make_loader(basedir, ['elements/target.bst']) - element = loader.load()[0] + loader = make_loader(basedir) + element = loader.load(['elements/target.bst'])[0] assert(isinstance(element, MetaElement)) assert(element.kind == 'pony') @@ -174,8 +174,8 @@ 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 = make_loader(basedir, ['elements/alldep.bst']) - element = loader.load()[0] + loader = make_loader(basedir) + element = loader.load(['elements/alldep.bst'])[0] assert(isinstance(element, MetaElement)) assert(element.kind == 'pony') |