diff options
author | bst-marge-bot <marge-bot@buildstream.build> | 2020-08-23 12:26:11 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2020-08-23 12:26:11 +0000 |
commit | 00c5cd05ec8fe04d72affc42d399ac546d36b5b5 (patch) | |
tree | fe9b0a8190f21e5685ff12ceaf9f1d5ebc2dd763 | |
parent | 0f1b547c9125a1bbf267136e48ba235e8814d5a2 (diff) | |
parent | 2d1fd2caf44f0f6a268d1369a9b4533300fc285d (diff) | |
download | buildstream-00c5cd05ec8fe04d72affc42d399ac546d36b5b5.tar.gz |
Merge branch 'bschubert/stricter-thread-checks' into 'master'
_fixtures.py: Only get the normal number of threads at the start of session
See merge request BuildStream/buildstream!2038
-rw-r--r-- | src/buildstream/testing/_fixtures.py | 15 | ||||
-rw-r--r-- | src/buildstream/testing/_sourcetests/conftest.py | 2 | ||||
-rwxr-xr-x | tests/conftest.py | 6 |
3 files changed, 17 insertions, 6 deletions
diff --git a/src/buildstream/testing/_fixtures.py b/src/buildstream/testing/_fixtures.py index 5da51bb45..98778936d 100644 --- a/src/buildstream/testing/_fixtures.py +++ b/src/buildstream/testing/_fixtures.py @@ -14,19 +14,26 @@ # You should have received a copy of the GNU Lesser General Public # License along with this library. If not, see <http://www.gnu.org/licenses/>. +# pylint: disable=redefined-outer-name + import psutil import pytest from buildstream import node, utils -# Catch tests that don't shut down background threads, which could then lead -# to other tests hanging when BuildStream uses fork(). -@pytest.fixture(autouse=True) -def thread_check(): + +@pytest.fixture(autouse=True, scope="session") +def default_thread_number(): # xdist/execnet has its own helper thread. # Ignore that for `utils._is_single_threaded` checks. utils._INITIAL_NUM_THREADS_IN_MAIN_PROCESS = psutil.Process().num_threads() + +# Catch tests that don't shut down background threads, which could then lead +# to other tests hanging when BuildStream uses fork(). +@pytest.fixture(autouse=True) +def thread_check(default_thread_number): + assert utils._is_single_threaded() yield assert utils._is_single_threaded() diff --git a/src/buildstream/testing/_sourcetests/conftest.py b/src/buildstream/testing/_sourcetests/conftest.py index 64dd404ef..6790712a9 100644 --- a/src/buildstream/testing/_sourcetests/conftest.py +++ b/src/buildstream/testing/_sourcetests/conftest.py @@ -14,4 +14,4 @@ # You should have received a copy of the GNU Lesser General Public # License along with this library. If not, see <http://www.gnu.org/licenses/>. -from .._fixtures import reset_global_node_state, thread_check # pylint: disable=unused-import +from .._fixtures import reset_global_node_state, default_thread_number, thread_check # pylint: disable=unused-import diff --git a/tests/conftest.py b/tests/conftest.py index 28e120d5e..476113105 100755 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -25,7 +25,11 @@ import pkg_resources import pytest from buildstream.testing import register_repo_kind, sourcetests_collection_hook -from buildstream.testing._fixtures import reset_global_node_state, thread_check # pylint: disable=unused-import +from buildstream.testing._fixtures import ( # pylint: disable=unused-import + default_thread_number, + reset_global_node_state, + thread_check, +) from buildstream.testing.integration import integration_cache # pylint: disable=unused-import |