diff options
author | bst-marge-bot <marge-bot@buildstream.build> | 2020-05-30 13:18:18 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2020-05-30 13:18:18 +0000 |
commit | 925a6ab5339c6223ced1700024a41debe5c15c39 (patch) | |
tree | fac39a6e93d4834dbea5d38fce8514399dff60dd | |
parent | f2a5dbe9f888d5b8a4fc4e6abd666fde722bc8f7 (diff) | |
parent | 49ab0bc22c66e12651ecc1fecd3511cfcd916b3e (diff) | |
download | buildstream-925a6ab5339c6223ced1700024a41debe5c15c39.tar.gz |
Merge branch 'tristan/remove-loader-no-progress-object' into 'master'
loader: removing the NO_PROGRESS object
See merge request BuildStream/buildstream!1947
-rw-r--r-- | src/buildstream/_loader/loader.py | 15 | ||||
-rw-r--r-- | tests/internals/loader.py | 15 |
2 files changed, 12 insertions, 18 deletions
diff --git a/src/buildstream/_loader/loader.py b/src/buildstream/_loader/loader.py index 37e00ad4b..ae729f243 100644 --- a/src/buildstream/_loader/loader.py +++ b/src/buildstream/_loader/loader.py @@ -37,11 +37,6 @@ from ..types import CoreWarnings, _KeyStrength from .._message import Message, MessageType -# This should be used to deliberately disable progress reporting when -# collecting an element -_NO_PROGRESS = object() - - # Loader(): # # The Loader class does the heavy lifting of parsing target @@ -157,7 +152,7 @@ class Loader: self._clean_caches() # Cache how many Elements have just been loaded - if task is not _NO_PROGRESS: + if task: # Workaround for task potentially being None (because no State object) self.loaded = task.current_progress @@ -232,7 +227,7 @@ class Loader: # # Any task counting *inside* the junction will be handled by # its loader. - meta_element = self._collect_element_no_deps(self._elements[filename], _NO_PROGRESS) + meta_element = self._collect_element_no_deps(self._elements[filename]) if meta_element.kind != "junction": raise LoadError( "{}{}: Expected junction but element kind is {}".format(provenance_str, filename, meta_element.kind), @@ -598,7 +593,7 @@ class Loader: # Returns: # (MetaElement): A partially loaded MetaElement # - def _collect_element_no_deps(self, element, task): + def _collect_element_no_deps(self, element, task=None): # Return the already built one, if we already built it meta_element = self._meta_elements.get(element.name) if meta_element: @@ -654,7 +649,7 @@ class Loader: # Cache it now, make sure it's already there before recursing self._meta_elements[element.name] = meta_element - if task is not _NO_PROGRESS: + if task: task.add_current_progress() return meta_element @@ -670,7 +665,7 @@ class Loader: # Returns: # (MetaElement): A fully loaded MetaElement # - def _collect_element(self, top_element, task): + def _collect_element(self, top_element, task=None): element_queue = [top_element] meta_element_queue = [self._collect_element_no_deps(top_element, task)] diff --git a/tests/internals/loader.py b/tests/internals/loader.py index 6fdd9fc3a..408813a64 100644 --- a/tests/internals/loader.py +++ b/tests/internals/loader.py @@ -6,7 +6,6 @@ from buildstream.exceptions import LoadErrorReason from buildstream._exceptions import LoadError from buildstream._project import Project from buildstream._loader import MetaElement -from buildstream._loader.loader import _NO_PROGRESS from tests.testutils import dummy_context @@ -29,7 +28,7 @@ def test_one_file(datafiles): basedir = str(datafiles) with make_loader(basedir) as loader: - element = loader.load(["elements/onefile.bst"], _NO_PROGRESS)[0] + element = loader.load(["elements/onefile.bst"], None)[0] assert isinstance(element, MetaElement) assert element.kind == "pony" @@ -40,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"], _NO_PROGRESS) + loader.load(["elements/missing.bst"], None) assert exc.value.reason == LoadErrorReason.MISSING_FILE @@ -50,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"], _NO_PROGRESS) + loader.load(["elements/badreference.bst"], None) assert exc.value.reason == LoadErrorReason.INVALID_YAML @@ -60,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"], _NO_PROGRESS) + loader.load(["elements/badfile.bst"], None) assert exc.value.reason == LoadErrorReason.INVALID_YAML @@ -72,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], _NO_PROGRESS) + loader.load([fullpath], None) assert exc.value.reason == LoadErrorReason.INVALID_DATA @@ -82,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"], _NO_PROGRESS) + loader.load(["elements/invalidkey.bst"], None) assert exc.value.reason == LoadErrorReason.INVALID_DATA @@ -92,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/"], _NO_PROGRESS) + loader.load(["elements/"], None) assert exc.value.reason == LoadErrorReason.LOADING_DIRECTORY |