diff options
author | Christoph Reiter <reiter.christoph@gmail.com> | 2019-10-18 22:19:33 +0200 |
---|---|---|
committer | Christoph Reiter <reiter.christoph@gmail.com> | 2019-10-19 00:18:57 +0200 |
commit | 15ae632842cb7722d0ac4bd2f8c08ab2f3befea5 (patch) | |
tree | eae3d6d3c5675d80f3dc218e80e8ab15ce5f4994 | |
parent | e29b06546454a43ff4d138ce08618fa8664643fe (diff) | |
download | pygobject-15ae632842cb7722d0ac4bd2f8c08ab2f3befea5.tar.gz |
CI: Use gnome-master for testing with gtk4
This makes it easier to track upstream changes without us having to
rebuild docker images.
Downside is that we don't control it and API is still changing,
so allow the job to fail.
-rw-r--r-- | .gitlab-ci.yml | 17 | ||||
-rw-r--r-- | .gitlab-ci/Dockerfile.gtk4 | 28 | ||||
-rwxr-xr-x | .gitlab-ci/run-docker-gtk4.sh | 10 | ||||
-rwxr-xr-x | .gitlab-ci/run-docker-runtime.sh | 2 | ||||
-rwxr-xr-x | .gitlab-ci/test-docker-gtk4.sh | 19 | ||||
-rwxr-xr-x | .gitlab-ci/test-flatpak-gtk4.sh | 13 | ||||
-rwxr-xr-x | .gitlab-ci/test-flatpak.sh | 2 | ||||
-rw-r--r-- | gi/overrides/Gtk.py | 28 | ||||
-rw-r--r-- | tests/test_gtk_template.py | 13 | ||||
-rw-r--r-- | tests/test_overrides_gtk.py | 16 |
10 files changed, 53 insertions, 95 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 33d6bc59..62818e4c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -111,18 +111,19 @@ xenial-i386-py2: script: - bash -x ./.gitlab-ci/test-docker-old.sh -gtk4: +gnome-master: + allow_failure: true stage: build_and_test - image: registry.gitlab.gnome.org/gnome/pygobject/gtk4:v4 - artifacts: - paths: - - coverage/ + image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master script: - - bash -x ./.gitlab-ci/test-docker-gtk4.sh + - 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: +gnome-master-gtk4: allow_failure: true stage: build_and_test image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master script: - - xvfb-run -a flatpak run --filesystem=host --share=network --socket=x11 --command=bash org.gnome.Sdk//master -x .gitlab-ci/test-flatpak.sh + - 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/.gitlab-ci/Dockerfile.gtk4 b/.gitlab-ci/Dockerfile.gtk4 deleted file mode 100644 index a1e60348..00000000 --- a/.gitlab-ci/Dockerfile.gtk4 +++ /dev/null @@ -1,28 +0,0 @@ -FROM registry.gitlab.gnome.org/gnome/pygobject/main:v11 - -USER root - -RUN python3 -m pip install meson==0.49.2 - -ENV DEBIAN_FRONTEND noninteractive -RUN apt-get update && apt-get install -y \ - libfribidi-dev \ - libgraphene-1.0-dev \ - libgstreamer-plugins-bad1.0-dev \ - libgtk-3-dev \ - libwayland-dev \ - libxml2-dev \ - wayland-protocols \ - && rm -rf /var/lib/apt/lists/* - -RUN git clone https://gitlab.gnome.org/GNOME/gtk.git \ - && cd gtk \ - && git checkout 833442e1e29e5 \ - && meson -Dprefix=/usr -Dbuild-tests=false -Ddemos=false -Dbuild-examples=false -Dprint-backends=none _build \ - && ninja -C _build \ - && ninja -C _build install \ - && cd .. \ - && rm -Rf gtk - -USER user -ENV PYENV_VERSION 3.7.3-debug diff --git a/.gitlab-ci/run-docker-gtk4.sh b/.gitlab-ci/run-docker-gtk4.sh deleted file mode 100755 index e2de0858..00000000 --- a/.gitlab-ci/run-docker-gtk4.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -set -e - -TAG="registry.gitlab.gnome.org/gnome/pygobject/gtk4:v4" - -sudo docker build --tag "${TAG}" --file "Dockerfile.gtk4" . -sudo docker run --rm --security-opt label=disable \ - --volume "$(pwd)/..:/home/user/app" --workdir "/home/user/app" \ - --tty --interactive "${TAG}" bash diff --git a/.gitlab-ci/run-docker-runtime.sh b/.gitlab-ci/run-docker-runtime.sh index 0205ec6c..d70cba3c 100755 --- a/.gitlab-ci/run-docker-runtime.sh +++ b/.gitlab-ci/run-docker-runtime.sh @@ -8,4 +8,4 @@ sudo docker pull "${TAG}" sudo docker run --privileged --rm --security-opt label=disable \ --volume "$(pwd)/..:/home/user/app" --workdir "/home/user/app" \ --tty --interactive "${TAG}" xvfb-run -a flatpak run --filesystem=host \ - --share=network --socket=x11 --command=bash org.gnome.Sdk//master + --share=network --socket=x11 --devel --command=bash org.gnome.Sdk//master diff --git a/.gitlab-ci/test-docker-gtk4.sh b/.gitlab-ci/test-docker-gtk4.sh deleted file mode 100755 index 0dd12199..00000000 --- a/.gitlab-ci/test-docker-gtk4.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -set -e - -# ccache setup -export CCACHE_BASEDIR="$(pwd)" -export CCACHE_DIR="${CCACHE_BASEDIR}/_ccache" -COV_DIR="$(pwd)/coverage" -export COVERAGE_FILE="${COV_DIR}/.coverage.${CI_JOB_NAME}" -mkdir -p "${COV_DIR}" -mkdir -p "${CCACHE_DIR}" - -# test -python -m pip install git+https://github.com/pygobject/pycairo.git -python -m pip install pytest pytest-faulthandler coverage -g-ir-inspect Gtk --version=4.0 --print-typelibs -export TEST_GTK_VERSION=4.0 -python setup.py build_tests -xvfb-run -a python -m coverage run tests/runtests.py diff --git a/.gitlab-ci/test-flatpak-gtk4.sh b/.gitlab-ci/test-flatpak-gtk4.sh new file mode 100755 index 00000000..189d63cd --- /dev/null +++ b/.gitlab-ci/test-flatpak-gtk4.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -e + +COV_DIR="$(pwd)/coverage" +export COVERAGE_FILE="${COV_DIR}/.coverage.gtk4" +mkdir -p "${COV_DIR}" + +export TEST_GTK_VERSION=4.0 +python3 -m pip install --user pytest pytest-faulthandler coverage +python3 setup.py build_tests +python3 -m coverage run tests/runtests.py +chmod -R 777 "${COV_DIR}"
\ No newline at end of file diff --git a/.gitlab-ci/test-flatpak.sh b/.gitlab-ci/test-flatpak.sh index 0dd01c46..b76eefa6 100755 --- a/.gitlab-ci/test-flatpak.sh +++ b/.gitlab-ci/test-flatpak.sh @@ -6,4 +6,4 @@ python3 -m pip install --user pytest pytest-faulthandler # for some reason pip3 fails the first time now.. # https://gitlab.com/freedesktop-sdk/freedesktop-sdk/issues/776 python3 -m pip install --user pytest pytest-faulthandler -python3 setup.py test -s +python3 setup.py test -s
\ No newline at end of file diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py index b5c2dd06..3ea02ae1 100644 --- a/gi/overrides/Gtk.py +++ b/gi/overrides/Gtk.py @@ -137,9 +137,10 @@ class Widget(Gtk.Widget): translate_coordinates = strip_boolean_result(Gtk.Widget.translate_coordinates) - def freeze_child_notify(self): - super(Widget, self).freeze_child_notify() - return _FreezeNotifyManager(self) + if Gtk._version != "4.0": + def freeze_child_notify(self): + super(Widget, self).freeze_child_notify() + return _FreezeNotifyManager(self) if Gtk._version != "4.0": def drag_dest_set_target_list(self, target_list): @@ -186,18 +187,19 @@ class Container(Gtk.Container, Widget): # alias for Python 2.x object protocol __nonzero__ = __bool__ - def child_get_property(self, child, property_name, value=None): - if value is None: - prop = self.find_child_property(property_name) - if prop is None: - raise ValueError('Class "%s" does not contain child property "%s"' % - (self, property_name)) - value = GObject.Value(prop.value_type) + if Gtk._version in ("2.0", "3.0"): - Gtk.Container.child_get_property(self, child, property_name, value) - return value.get_value() + def child_get_property(self, child, property_name, value=None): + if value is None: + prop = self.find_child_property(property_name) + if prop is None: + raise ValueError('Class "%s" does not contain child property "%s"' % + (self, property_name)) + value = GObject.Value(prop.value_type) + + Gtk.Container.child_get_property(self, child, property_name, value) + return value.get_value() - if Gtk._version in ("2.0", "3.0"): def child_get(self, child, *prop_names): """Returns a list of child property values for the given names.""" return [self.child_get_property(child, name) for name in prop_names] diff --git a/tests/test_gtk_template.py b/tests/test_gtk_template.py index ee197d0f..3a1c1f02 100644 --- a/tests/test_gtk_template.py +++ b/tests/test_gtk_template.py @@ -190,18 +190,17 @@ def test_main_example(): assert w.goodbye_button.props.label == "Goodbye World" assert w.callback_hello == [] - w._hello_button.clicked() + w._hello_button.emit("clicked") assert w.callback_hello == [(w,)] assert w.callback_hello_after == [(w,)] assert w.callback_goodbye == [] - w.goodbye_button.clicked() + w.goodbye_button.emit("clicked") assert w.callback_goodbye == [(w.goodbye_button,)] assert w.callback_goodbye_after == [(w.goodbye_button,)] def test_duplicate_handler(): - type_name = new_gtype_name() xml = """\ @@ -209,7 +208,7 @@ def test_duplicate_handler(): <template class="{0}" parent="GtkBox"> <child> <object class="GtkButton" id="hello_button"> - <signal name="clicked" handler="hello_button_clicked"> + <signal name="clicked" handler="hello_button_clicked" /> </object> </child> </template> @@ -300,7 +299,6 @@ def test_missing_handler_callback(): def test_handler_swapped_not_supported(): - type_name = new_gtype_name() xml = """\ @@ -332,7 +330,6 @@ def test_handler_swapped_not_supported(): def test_handler_class_staticmethod(): - type_name = new_gtype_name() xml = """\ @@ -368,13 +365,13 @@ def test_handler_class_staticmethod(): signal_args_static.append(args) foo = Foo() - foo.hello_button.clicked() + foo.hello_button.emit("clicked") assert signal_args_class == [(Foo, foo.hello_button)] assert signal_args_static == [(foo.hello_button,)] +@pytest.mark.skipif(Gtk._version == "4.0", reason="errors out first with gtk4") def test_check_decorated_class(): - NonWidget = type("Foo", (object,), {}) with pytest.raises(TypeError, match=".*on Widgets.*"): Gtk.Template.from_string("")(NonWidget) diff --git a/tests/test_overrides_gtk.py b/tests/test_overrides_gtk.py index d791e240..9c32e8ba 100644 --- a/tests/test_overrides_gtk.py +++ b/tests/test_overrides_gtk.py @@ -56,7 +56,7 @@ def realized(widget): toplevel = widget else: if Gtk._version == "4.0": - toplevel = widget.get_parent_surface() + toplevel = widget.get_parent() else: toplevel = widget.get_parent_window() @@ -79,6 +79,7 @@ def realized(widget): @unittest.skipUnless(Gtk, 'Gtk not available') +@unittest.skipIf(Gtk_version == "4.0", "not in gtk4") def test_freeze_child_notif(): events = [] @@ -90,10 +91,7 @@ def test_freeze_child_notif(): c = Gtk.Button() c.connect("child-notify", on_notify) c.freeze_child_notify() - if GTK4: - b.pack_start(c) - else: - b.pack_start(c, True, True, 0) + b.pack_start(c, True, True, 0) b.child_set_property(c, "pack-type", Gtk.PackType.END) b.child_set_property(c, "pack-type", Gtk.PackType.START) c.thaw_child_notify() @@ -895,7 +893,10 @@ class TestSignals(unittest.TestCase): else: win.size_allocate(rect) self.assertTrue(win._alloc_called) - self.assertIsInstance(win._alloc_value, Gdk.Rectangle) + if GTK4: + self.assertIsInstance(win._alloc_value, int) + else: + self.assertIsInstance(win._alloc_value, Gdk.Rectangle) self.assertTrue(win._alloc_error is None, win._alloc_error) @unittest.expectedFailure # https://bugzilla.gnome.org/show_bug.cgi?id=735693 @@ -2699,11 +2700,12 @@ class TestContainer(unittest.TestCase): result = box.child_get_property(child, 'padding') self.assertEqual(result, 42) + @unittest.skipIf(Gtk_version == "4.0", "not in gtk4") def test_child_get_property_error(self): box = Gtk.Box() child = Gtk.Button() if Gtk_version == "4.0": - box.pack_start(child) + box.add(child) else: box.pack_start(child, expand=False, fill=True, padding=42) with self.assertRaises(ValueError): |