Commit 15ae6328 authored by Christoph Reiter's avatar Christoph Reiter 🐍

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.
parent e29b0654
......@@ -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
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
#!/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
......@@ -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
#!/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
#!/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
......@@ -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
......@@ -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]
......
......@@ -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)
......
......@@ -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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment