diff options
-rw-r--r-- | .gitlab-ci.yml | 11 | ||||
-rw-r--r-- | src/buildstream/element.py | 31 |
2 files changed, 36 insertions, 6 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index df0c26b89..be3c5fbe5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -211,6 +211,12 @@ tests-bb-remote-cache: tests-no-usedevelop: # Ensure that tests also pass without `--develop` flag. + # + # Our tox.ini file does not set `usedevelop` when running without coverage, + # but the `usedevelop` flag is required when collecting coverage information, + # this is why we provoke the tests to run with `nocover` in order to provoke + # the tests to run in CI without `usedevelop`. + # image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:32-${DOCKER_IMAGE_VERSION} <<: *tests variables: @@ -289,7 +295,7 @@ docs: image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:32-${DOCKER_IMAGE_VERSION} variables: FD_SDK_REF: freedesktop-sdk-20.08beta.1-buildstream2 - BST_EXT_REF: 1.93.4 + BST_EXT_REF: aa5b1bc2743ce01763567f88b16c8cd5f868ac6c before_script: - | mkdir -p "${HOME}/.config" @@ -354,8 +360,7 @@ overnight-randomized: - chown -R buildstream:buildstream . # Don't run tests multiprocessed here, the randomized order doesn't like that - - su buildstream -c "tox -e py36-randomized,py37-randomized,py38-randomized -- --color=yes --integration" - - su buildstream -c "tox -e py36-randomized-external,py37-randomized-external,py38-randomized-external -- --color=yes --integration" + - su buildstream -c "tox -e py36-randomized,py37-randomized,py38-randomized-nocover -- --color=yes --integration" # We need to override the exclusion from the template in order to run on schedules except: [] diff --git a/src/buildstream/element.py b/src/buildstream/element.py index 831b3e183..0aabe1be6 100644 --- a/src/buildstream/element.py +++ b/src/buildstream/element.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2016-2018 Codethink Limited +# Copyright (C) 2016-2020 Codethink Limited # Copyright (C) 2017-2020 Bloomberg Finance LP # # This program is free software; you can redistribute it and/or @@ -240,6 +240,8 @@ class Element(Plugin): # Private instance properties # + # Cache of proxies instantiated, indexed by the proxy owner + self.__proxies = {} # type: Dict[Element, ElementProxy] # Direct runtime dependency Elements self.__runtime_dependencies = [] # type: List[Element] # Direct build dependency Elements @@ -476,7 +478,7 @@ class Element(Plugin): # methods. # for dep in element._dependencies(scope, recurse=recurse, visited=visited): - yield cast("Element", ElementProxy(self, dep)) + yield cast("Element", dep.__get_proxy(self)) def search(self, name: str) -> Optional["Element"]: """Search for a dependency by name @@ -491,7 +493,7 @@ class Element(Plugin): if search is self: return self elif search: - return cast("Element", ElementProxy(self, search)) + return cast("Element", search.__get_proxy(self)) return None @@ -2297,6 +2299,29 @@ class Element(Plugin): # Private Local Methods # ############################################################# + # __get_proxy() + # + # Obtain a proxy for this element for the specified `owner`. + # + # We cache the proxies for plugin convenience, this allows plugins + # compare proxies to other proxies returned to them, so they + # can run valid statements such as `proxy_a is `proxy_b` or + # `proxy_a in list_of_proxies`. + # + # Args: + # owner (Element): The owning element + # + # Returns: + # (ElementProxy): An ElementProxy to self, for owner. + # + def __get_proxy(self, owner: "Element") -> ElementProxy: + with suppress(KeyError): + return self.__proxies[owner] + + proxy = ElementProxy(owner, self) + self.__proxies[owner] = proxy + return proxy + # __load_sources() # # Load the Source objects from the LoadElement |