diff options
author | Tristan van Berkom <tristan.vanberkom@codethink.co.uk> | 2020-06-14 21:23:19 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2020-06-16 16:18:21 +0000 |
commit | deb6562719c2ca90b5fbdc2974e8a77da8430a96 (patch) | |
tree | 8930acee7295640e355c4a957b4919653663ea11 /tests | |
parent | 3774ce42263b947b211c6bb54aea85a00caa561e (diff) | |
download | buildstream-deb6562719c2ca90b5fbdc2974e8a77da8430a96.tar.gz |
_loader: Adding LoadContexttristan/load-context
Instead of passing around many details though calling signatures
throughout the loader code, create a single LoadContext object
which holds any overall loading state along with any values which
are constant to a full load process.
Overall this patch does:
* _frontend/app.py: No need to pass Stream.fetch_subprojects() along anymore
* _loader/loadelement.pyx: collect_element_no_deps() no longer takes a task argument
* _loader/loader.py: Now the Loader has a `load_context` member, and no more
`_fetch_subprojects` member or `_context` members
Further, `rewritable` and `ticker` is no longer passed along through all
of the recursing calling signatures, and `ticker` itself is finally removed
because this has been replaced a long time ago with `Task` API from `State`.
* _pipeline.py: The load() function no longer has a `rewritable` parameter
* _project.py: The Project() is responsible for creating the toplevel
LoadContext() if one doesn't exist yet, and this is passed through
to the Loader() (and also passed to the Project() constructor by the
Loader() when instantiating subprojects).
* _stream.py: The `Stream._fetch_subprojects()` is now private and set
on the project when giving the Project to the Stream in `Stream.set_project()`,
also the Stream() sets the `rewritable` state on the `LoadContext` at the
earliest opportunity, as the `Stream()` is the one who decides this detail.
Further, some double underscore private functions are now regular single
underscores, there was no reason for this inconsistency.
* tests/internals/loader.py: Updated for API change
Diffstat (limited to 'tests')
-rw-r--r-- | tests/internals/loader.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/internals/loader.py b/tests/internals/loader.py index 408813a64..bdce428f0 100644 --- a/tests/internals/loader.py +++ b/tests/internals/loader.py @@ -28,7 +28,7 @@ def test_one_file(datafiles): basedir = str(datafiles) with make_loader(basedir) as loader: - element = loader.load(["elements/onefile.bst"], None)[0] + element = loader.load(["elements/onefile.bst"])[0] assert isinstance(element, MetaElement) assert element.kind == "pony" @@ -39,7 +39,7 @@ def test_missing_file(datafiles): basedir = str(datafiles) with make_loader(basedir) as loader, pytest.raises(LoadError) as exc: - loader.load(["elements/missing.bst"], None) + loader.load(["elements/missing.bst"]) assert exc.value.reason == LoadErrorReason.MISSING_FILE @@ -49,7 +49,7 @@ def test_invalid_reference(datafiles): basedir = str(datafiles) with make_loader(basedir) as loader, pytest.raises(LoadError) as exc: - loader.load(["elements/badreference.bst"], None) + loader.load(["elements/badreference.bst"]) assert exc.value.reason == LoadErrorReason.INVALID_YAML @@ -59,7 +59,7 @@ def test_invalid_yaml(datafiles): basedir = str(datafiles) with make_loader(basedir) as loader, pytest.raises(LoadError) as exc: - loader.load(["elements/badfile.bst"], None) + loader.load(["elements/badfile.bst"]) assert exc.value.reason == LoadErrorReason.INVALID_YAML @@ -71,7 +71,7 @@ def test_fail_fullpath_target(datafiles): fullpath = os.path.join(basedir, "elements", "onefile.bst") with make_loader(basedir) as loader, pytest.raises(LoadError) as exc: - loader.load([fullpath], None) + loader.load([fullpath]) assert exc.value.reason == LoadErrorReason.INVALID_DATA @@ -81,7 +81,7 @@ def test_invalid_key(datafiles): basedir = str(datafiles) with make_loader(basedir) as loader, pytest.raises(LoadError) as exc: - loader.load(["elements/invalidkey.bst"], None) + loader.load(["elements/invalidkey.bst"]) assert exc.value.reason == LoadErrorReason.INVALID_DATA @@ -91,6 +91,6 @@ def test_invalid_directory_load(datafiles): basedir = str(datafiles) with make_loader(basedir) as loader, pytest.raises(LoadError) as exc: - loader.load(["elements/"], None) + loader.load(["elements/"]) assert exc.value.reason == LoadErrorReason.LOADING_DIRECTORY |