[pygobject] Skip Regress tests with --disable-cairo



commit 75e373b99c3cb66dd60b13c803e5f7eec77cc415
Author: Martin Pitt <martinpitt gnome org>
Date:   Mon Oct 15 07:42:05 2012 +0200

    Skip Regress tests with --disable-cairo
    
    We need cairo to build g-i's Regress library, gir, and typelib. Update
    configure.ac to only require cairo if --disable-cairo was not given. With
    --disable-cairo, skip building the Regress library and skip all tests which use
    it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=685094

 configure.ac             |    5 ++---
 tests/Makefile.am        |   45 +++++++++++++++++++++++++++------------------
 tests/test_everything.py |   15 +++++++++++----
 tests/test_overrides.py  |    7 ++++++-
 4 files changed, 46 insertions(+), 26 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a135b2b..c72c261 100644
--- a/configure.ac
+++ b/configure.ac
@@ -184,9 +184,6 @@ AC_SUBST(LIBFFI_PC)
 dnl gio
 PKG_CHECK_MODULES(GIO, gio-2.0 >= gio_required_version)
 
-# we always need cairo (not pycairo) for building the tests
-PKG_CHECK_MODULES(CAIRO, cairo cairo-gobject)
-
 AC_ARG_ENABLE(cairo,
     AC_HELP_STRING([--enable-cairo], [Enable Cairo bindings using introspection information]),
     enable_cairo=$enableval,
@@ -201,6 +198,8 @@ GI_DATADIR=$($PKG_CONFIG --variable=gidatadir gobject-introspection-1.0)
 AC_SUBST(GI_DATADIR)
 
 if test "$enable_cairo" != no; then
+    PKG_CHECK_MODULES(CAIRO, cairo cairo-gobject)
+
     if test $build_py3k = true; then
         PKG_CHECK_MODULES(PYCAIRO,
             py3cairo >= py3cairo_required_version
diff --git a/tests/Makefile.am b/tests/Makefile.am
index db58f69..7a619bf 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,20 +1,37 @@
 CLEANFILES =
-noinst_LTLIBRARIES = libregress.la libgimarshallingtests.la
+noinst_LTLIBRARIES = libgimarshallingtests.la
+test_typelibs = GIMarshallingTests-1.0.typelib
 
-nodist_libregress_la_SOURCES = $(GI_DATADIR)/tests/regress.c $(GI_DATADIR)/tests/regress.h
-libregress_la_CFLAGS = $(GIO_CFLAGS) $(CAIRO_CFLAGS)
-libregress_la_LDFLAGS = -module -avoid-version $(GIO_LIBS) $(CAIRO_LIBS)
 nodist_libgimarshallingtests_la_SOURCES = $(GI_DATADIR)/tests/gimarshallingtests.c $(GI_DATADIR)/tests/gimarshallingtests.h
 libgimarshallingtests_la_CFLAGS = $(GLIB_CFLAGS)
 libgimarshallingtests_la_LDFLAGS = -module -avoid-version $(GLIB_LIBS)
 
 # This is a hack to make sure a shared library is built
-libregress.la: $(libregress_la_OBJECTS) $(libregress_la_DEPENDENCIES)
-	$(LINK) -rpath $(pkgpyexecdir) $(libregress_la_LDFLAGS) $(libregress_la_OBJECTS) $(libregress_la_LIBADD) $(LIBS)
-
 libgimarshallingtests.la: $(libgimarshallingtests_la_OBJECTS) $(libgimarshallingtests_la_DEPENDENCIES)
 	$(LINK) -rpath $(pkgpyexecdir) $(libgimarshallingtests_la_LDFLAGS) $(libgimarshallingtests_la_OBJECTS) $(libgimarhallingtests_la_LIBADD) $(LIBS)
 
+GIMarshallingTests-1.0.gir: libgimarshallingtests.la Makefile
+	$(AM_V_GEN) g-ir-scanner --include=Gio-2.0 \
+	--namespace=GIMarshallingTests --nsversion=1.0 --symbol-prefix=gi_marshalling_tests \
+	--warn-all --warn-error \
+	--library=libgimarshallingtests.la \
+	--libtool="$(top_builddir)/libtool" \
+	--output $@ \
+	$(nodist_libgimarshallingtests_la_SOURCES)
+GIMarshallingTests-1.0.typelib: GIMarshallingTests-1.0.gir Makefile
+	$(AM_V_GEN) g-ir-compiler $< -o $@
+
+# regress.c needs cairo
+if ENABLE_CAIRO
+noinst_LTLIBRARIES += libregress.la
+test_typelibs += Regress-1.0.typelib
+nodist_libregress_la_SOURCES = $(GI_DATADIR)/tests/regress.c $(GI_DATADIR)/tests/regress.h
+libregress_la_CFLAGS = $(GIO_CFLAGS) $(CAIRO_CFLAGS)
+libregress_la_LDFLAGS = -module -avoid-version $(GIO_LIBS) $(CAIRO_LIBS)
+
+libregress.la: $(libregress_la_OBJECTS) $(libregress_la_DEPENDENCIES)
+	$(LINK) -rpath $(pkgpyexecdir) $(libregress_la_LDFLAGS) $(libregress_la_OBJECTS) $(libregress_la_LIBADD) $(LIBS)
+
 # g-i doesn't ship these as shared libraries anymore; we build them here
 Regress-1.0.gir: libregress.la Makefile
 	$(AM_V_GEN) g-ir-scanner --include=cairo-1.0 --include=Gio-2.0 \
@@ -27,16 +44,8 @@ Regress-1.0.gir: libregress.la Makefile
 Regress-1.0.typelib: Regress-1.0.gir Makefile
 	$(AM_V_GEN) g-ir-compiler $< -o $@
 
-GIMarshallingTests-1.0.gir: libgimarshallingtests.la Makefile
-	$(AM_V_GEN) g-ir-scanner --include=Gio-2.0 \
-	--namespace=GIMarshallingTests --nsversion=1.0 --symbol-prefix=gi_marshalling_tests \
-	--warn-all --warn-error \
-	--library=libgimarshallingtests.la \
-	--libtool="$(top_builddir)/libtool" \
-	--output $@ \
-	$(nodist_libgimarshallingtests_la_SOURCES)
-GIMarshallingTests-1.0.typelib: GIMarshallingTests-1.0.gir Makefile
-	$(AM_V_GEN) g-ir-compiler $< -o $@
+endif # ENABLE_CAIRO
+
 
 gschemas.compiled: org.gnome.test.gschema.xml
 	glib-compile-schemas --targetdir=. --schema-file=$<
@@ -114,7 +123,7 @@ RUN_TESTS_ENV_VARS= \
 	MALLOC_PERTURB_=85 \
 	TESTS_BUILDDIR=$(builddir)
 
-check-local: $(LTLIBRARIES:.la=.so) Regress-1.0.typelib GIMarshallingTests-1.0.typelib gschemas.compiled
+check-local: $(LTLIBRARIES:.la=.so) $(test_typelibs) gschemas.compiled
 	@echo "  CHECK  Pyflakes"
 	@if type pyflakes >/dev/null 2>&1; then pyflakes $(top_srcdir); else echo "skipped, pyflakes not installed"; fi
 	@echo "  CHECK  PEP8"
diff --git a/tests/test_everything.py b/tests/test_everything.py
index 4fddf65..600edbf 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -15,6 +15,7 @@ import copy
 try:
     import cairo
     has_cairo = True
+    from gi.repository import Regress as Everything
 except ImportError:
     has_cairo = False
 
@@ -22,7 +23,6 @@ except ImportError:
 from gi.repository import GObject
 from gi.repository import GLib
 from gi.repository import Gio
-from gi.repository import Regress as Everything
 
 try:
     from gi.repository import Gtk
@@ -37,9 +37,9 @@ else:
     UNICHAR = "â"
 
 
+ unittest skipUnless(has_cairo, 'built without cairo support')
 class TestEverything(unittest.TestCase):
 
-    @unittest.skipUnless(has_cairo, 'built without cairo support')
     def test_cairo_context(self):
         context = Everything.test_cairo_context_full_return()
         self.assertTrue(isinstance(context, cairo.Context))
@@ -48,7 +48,6 @@ class TestEverything(unittest.TestCase):
         context = cairo.Context(surface)
         Everything.test_cairo_context_none_in(context)
 
-    @unittest.skipUnless(has_cairo, 'built without cairo support')
     def test_cairo_surface(self):
         surface = Everything.test_cairo_surface_none_return()
         self.assertTrue(isinstance(surface, cairo.ImageSurface))
@@ -247,6 +246,7 @@ class TestEverything(unittest.TestCase):
             self.assertTrue('tests/test_everything.py", line' in tb, tb)
 
 
+ unittest skipUnless(has_cairo, 'built without cairo support')
 class TestNullableArgs(unittest.TestCase):
     def test_in_nullable_hash(self):
         Everything.test_ghash_null_in(None)
@@ -284,6 +284,7 @@ class TestNullableArgs(unittest.TestCase):
         self.assertEqual(None, Everything.TestObj.null_out())
 
 
+ unittest skipUnless(has_cairo, 'built without cairo support')
 class TestCallbacks(unittest.TestCase):
     called = False
     main_loop = GObject.MainLoop()
@@ -553,6 +554,7 @@ class TestCallbacks(unittest.TestCase):
         self.assertEqual(mydict, {'foo': 1, 'bar': 2, 'new': 42})
 
 
+ unittest skipUnless(has_cairo, 'built without cairo support')
 class TestClosures(unittest.TestCase):
     def test_int_arg(self):
         def callback(num):
@@ -588,6 +590,7 @@ class TestClosures(unittest.TestCase):
         self.assertFalse(self.called)
 
 
+ unittest skipUnless(has_cairo, 'built without cairo support')
 class TestProperties(unittest.TestCase):
 
     def test_basic(self):
@@ -676,6 +679,7 @@ class TestProperties(unittest.TestCase):
         self.assertEqual(a.props.list, ["str1", "str2"])
 
 
+ unittest skipUnless(has_cairo, 'built without cairo support')
 class TestTortureProfile(unittest.TestCase):
     def test_torture_profile(self):
         import time
@@ -738,6 +742,7 @@ class TestTortureProfile(unittest.TestCase):
         print("\tTotal: %f sec" % total_time)
 
 
+ unittest skipUnless(has_cairo, 'built without cairo support')
 class TestAdvancedInterfaces(unittest.TestCase):
     def test_array_objs(self):
         obj1, obj2 = Everything.test_array_fixed_out_objects()
@@ -762,6 +767,7 @@ class TestAdvancedInterfaces(unittest.TestCase):
         self.assertEqual(ret, None)
 
 
+ unittest skipUnless(has_cairo, 'built without cairo support')
 class TestSignals(unittest.TestCase):
     def test_object_param_signal(self):
         obj = Everything.TestObj()
@@ -829,8 +835,9 @@ class TestSignals(unittest.TestCase):
         self.assertEqual(obj.callback_i, GObject.G_MAXUINT64)
 
 
+ unittest skipUnless(has_cairo, 'built without cairo support')
+ unittest skipUnless(Gtk, 'Gtk not available')
 class TestPango(unittest.TestCase):
-    @unittest.skipUnless(Gtk, 'Gtk not available')
     def test_cairo_font_options(self):
         screen = Gtk.Window().get_screen()
         font_opts = screen.get_font_options()
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index b0a5305..dd2aa6a 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -4,7 +4,11 @@
 import unittest
 
 import gi.overrides
-from gi.repository import Regress
+try:
+    from gi.repository import Regress
+    Regress  # pyflakes
+except ImportError:
+    Regress = None
 
 
 class TestRegistry(unittest.TestCase):
@@ -18,6 +22,7 @@ class TestRegistry(unittest.TestCase):
         except TypeError as e:
             self.assertTrue('Can not override a type MyClass' in str(e))
 
+    @unittest.skipUnless(Regress, 'built without cairo support')
     def test_separate_path(self):
         # Regress override is in tests/gi/overrides, separate from gi/overrides
         # https://bugzilla.gnome.org/show_bug.cgi?id=680913



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]