[pygobject/benzea/gio-asyncio] test
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/benzea/gio-asyncio] test
- Date: Thu, 18 Nov 2021 10:41:45 +0000 (UTC)
commit baa4546cec335fe1a7f035b485059c2674df690e
Author: Benjamin Berg <bberg redhat com>
Date: Wed Nov 17 21:05:28 2021 +0100
test
.gitlab-ci.yml | 104 +++++++++++++++++++++++++--------------------------
gi/events.py | 18 +++++++++
tests/meson.build | 3 +-
tests/runtests.py | 6 +++
tests/test_events.py | 39 +++++++++++++++++++
5 files changed, 117 insertions(+), 53 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index de9d9b0b..ba852c19 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -52,35 +52,35 @@ pages:
only:
- master
-mingw32:
- variables:
- MSYSTEM: "MINGW32"
- <<: *mingw-defaults
-
-mingw64:
- variables:
- MSYSTEM: "MINGW64"
- <<: *mingw-defaults
+#mingw32:
+# variables:
+# MSYSTEM: "MINGW32"
+# <<: *mingw-defaults
+#
+#mingw64:
+# variables:
+# MSYSTEM: "MINGW64"
+# <<: *mingw-defaults
python3.6:
variables:
PYENV_VERSION: "3.6.12"
<<: *defaults
-python3.7:
- variables:
- PYENV_VERSION: "3.7.9-debug"
- <<: *defaults
-
-python3.8:
- variables:
- PYENV_VERSION: "3.8.5-debug"
- <<: *defaults
-
-python3.9:
- variables:
- PYENV_VERSION: "3.9.0-debug"
- <<: *defaults
+#python3.7:
+# variables:
+# PYENV_VERSION: "3.7.9-debug"
+# <<: *defaults
+#
+#python3.8:
+# variables:
+# PYENV_VERSION: "3.8.5-debug"
+# <<: *defaults
+#
+#python3.9:
+# variables:
+# PYENV_VERSION: "3.9.0-debug"
+# <<: *defaults
pypy3.6:
allow_failure: true
@@ -88,32 +88,32 @@ pypy3.6:
PYENV_VERSION: "pypy3.6-7.3.1"
<<: *defaults
-old-i386-py3:
- stage: build_and_test
- image: registry.gitlab.gnome.org/gnome/pygobject/old:v4
- artifacts:
- paths:
- - coverage/
- script:
- - bash -x ./.gitlab-ci/test-docker-old.sh
-
-gnome-master:
- allow_failure: true
- stage: build_and_test
- image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master
- tags:
- - flatpak
- script:
- - xvfb-run -a flatpak run --filesystem=host --share=network --socket=x11 --command=bash
org.gnome.Sdk//master -x .gitlab-ci/test-flatpak.sh
-
-gnome-master-gtk4:
- allow_failure: true
- stage: build_and_test
- image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master
- tags:
- - flatpak
- script:
- - xvfb-run -a flatpak run --filesystem=host --share=network --socket=x11 --command=bash
org.gnome.Sdk//master -x .gitlab-ci/test-flatpak-gtk4.sh
- artifacts:
- paths:
- - coverage/
\ No newline at end of file
+#old-i386-py3:
+# stage: build_and_test
+# image: registry.gitlab.gnome.org/gnome/pygobject/old:v4
+# artifacts:
+# paths:
+# - coverage/
+# script:
+# - bash -x ./.gitlab-ci/test-docker-old.sh
+#
+#gnome-master:
+# allow_failure: true
+# stage: build_and_test
+# image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master
+# tags:
+# - flatpak
+# script:
+# - xvfb-run -a flatpak run --filesystem=host --share=network --socket=x11 --command=bash
org.gnome.Sdk//master -x .gitlab-ci/test-flatpak.sh
+#
+#gnome-master-gtk4:
+# allow_failure: true
+# stage: build_and_test
+# image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master
+# tags:
+# - flatpak
+# script:
+# - xvfb-run -a flatpak run --filesystem=host --share=network --socket=x11 --command=bash
org.gnome.Sdk//master -x .gitlab-ci/test-flatpak-gtk4.sh
+# artifacts:
+# paths:
+# - coverage/
\ No newline at end of file
diff --git a/gi/events.py b/gi/events.py
index 189a687b..e90e6c8d 100644
--- a/gi/events.py
+++ b/gi/events.py
@@ -93,8 +93,10 @@ class GLibEventLoop(asyncio.SelectorEventLoop):
finalizer=self._asyncgen_finalizer_hook)
try:
events._set_running_loop(self)
+ print("running mainloop")
g_main_loop_run(self._main_loop)
finally:
+ print("mainloop quit")
self._context.release()
self._thread_id = None
events._set_running_loop(None)
@@ -103,6 +105,7 @@ class GLibEventLoop(asyncio.SelectorEventLoop):
except AttributeError:
pass
sys.set_asyncgen_hooks(*old_agen_hooks)
+ print("run_forever done")
def time(self):
return GLib.get_monotonic_time() / 1000000
@@ -119,13 +122,19 @@ class GLibEventLoop(asyncio.SelectorEventLoop):
def stop(self):
# Simply quit the mainloop
+ print("stopping")
self._main_loop.quit()
+ print("stopped")
def close(self):
super().close()
for s in list(self.__signal_handlers):
self.remove_signal_handler(s)
+ def __del__(self, *args):
+ print("deleting", self, args)
+ super().__del__(*args)
+
if sys.platform != "win32":
def add_signal_handler(self, sig, callback, *args):
"""Add a handler for UNIX signal"""
@@ -329,6 +338,7 @@ class _Source(GLib.Source):
def prepare(self):
timeout = self._loop()._get_timeout_ms()
+ print("preparing with timeout", timeout)
# NOTE: Always return False, FDs are queried in check and the timeout
# needs to be rechecked anyway.
@@ -350,17 +360,21 @@ class _Source(GLib.Source):
timeout = self._loop()._get_timeout_ms()
if timeout == 0:
+ print("check returns ready due to timeout")
return True
+ print("checking with timeout", timeout)
return bool(ready)
def dispatch(self, callback, args):
+ print("dispatching")
# Now, wag the dog by its tail
self._dispatching = True
try:
self._loop()._run_once()
finally:
self._dispatching = False
+ print("done dispatching")
return GLib.SOURCE_CONTINUE
@@ -426,6 +440,10 @@ class _Selector(selectors.BaseSelector):
return key
+ def __del__(self, *args):
+ print("deleting", self, args)
+ super().__del__(*args)
+
# We could override modify, but it is only slightly when the "events" change.
def get_key(self, fileobj):
diff --git a/tests/meson.build b/tests/meson.build
index 6a25688e..ea725fc1 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -126,8 +126,9 @@ if pycairo_dep.found() and pycairo_dep.type_name() == 'internal'
endif
envdata.append('PYTHONPATH', python_paths)
envdata.append('TESTS_BUILDDIR', meson.current_build_dir())
+envdata.append('PYGI_TEST_VERBOSE', '1')
test('pygobject-test-suite', python,
args : [join_paths(meson.current_source_dir(), 'runtests.py')],
env : envdata,
- timeout : 90)
+ timeout : 20)
diff --git a/tests/runtests.py b/tests/runtests.py
index 721b5d80..932b8cb4 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -6,6 +6,12 @@ import sys
import pytest
+# Try to generate backtrace if meson kills as with SIGTERM:
+# will not work if the mainloop is overriding SIGTERM
+import signal
+def r(*args):
+ raise KeyboardInterrupt()
+signal.signal(signal.SIGTERM, r)
def main(argv):
if '--help' in argv:
diff --git a/tests/test_events.py b/tests/test_events.py
index 6b4cca5f..7e188d83 100644
--- a/tests/test_events.py
+++ b/tests/test_events.py
@@ -26,6 +26,7 @@ except ImportError:
warnings.warn('Upstream test_asyncio module has missing files!')
raise unittest.SkipTest('Upstream test_asyncio module has missing files!')
+import os
import sys
import gi
import gi.events
@@ -33,18 +34,56 @@ from gi.repository import GLib
import asyncio
import threading
+from test import support
+from asyncio import base_events
+
+orig = base_events._run_until_complete_cb
+def wrapper(*args):
+ print("run until complete future completed", args)
+ orig(*args)
+base_events._run_until_complete_cb = wrapper
# None of this currently works on Windows
if sys.platform != 'win32':
class GLibEventLoopTests(UnixEventLoopTestsMixin, test_utils.TestCase):
+ def setUp(self):
+ print("running", os.environ['PYTEST_CURRENT_TEST'])
+ super().setUp()
+
+ def tearDown(self):
+ print("tearing down")
+ asyncio.set_child_watcher(None)
+
+ # just in case if we have transport close callbacks
+ if not self.loop.is_closed():
+ test_utils.run_briefly(self.loop)
+
+ print("ran briefly if needed")
+
+ self.doCleanups()
+ print("cleanups done")
+ support.gc_collect()
+ print("gc collected")
+ test_utils.TestCase.tearDown(self)
+ print('test case tear down done')
+
def create_event_loop(self):
return gi.events.GLibEventLoop(main_context=GLib.MainContext.default())
+ def test_run_until_complete(self):
+ t0 = self.loop.time()
+ print("running mainloop with 0.1 sleep")
+ self.loop.run_until_complete(asyncio.sleep(0.1))
+ print("done running mainloop")
+ t1 = self.loop.time()
+ self.assertTrue(0.08 <= t1-t0 <= 0.8, t1-t0)
+
class SubprocessWatcherTests(SubprocessMixin, test_utils.TestCase):
def setUp(self):
+ print("running", os.environ['PYTEST_CURRENT_TEST'])
super().setUp()
policy = gi.events.GLibEventLoopPolicy()
asyncio.set_event_loop_policy(policy)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]