From: Nick Bowler Date: Wed, 3 Mar 2021 07:00:49 +0000 (-0500) Subject: Fix testsuite on ancient GLib. X-Git-Url: https://git.draconx.ca/gitweb/gob-dx.git/commitdiff_plain/a26eff8ba11dcf9a6aa21e1537397bbbfb6a927e Fix testsuite on ancient GLib. Some test cases use private data members and these fail with glib-2.0 as this feature was added somewhere around glib-2.4 or so. Since the program itself works fine with glib-2.0, add a configure check to skip affected tests in this scenario. --- diff --git a/Makefile.am b/Makefile.am index a693ace..84a4d95 100644 --- a/Makefile.am +++ b/Makefile.am @@ -211,6 +211,7 @@ atlocal: config.status LIBGOBJECT_CFLAGS '$(LIBGOBJECT_CFLAGS)' \ LIBGOBJECT_LIBS '$(LIBGOBJECT_LIBS)' \ HAVE_GOBJECT '$(HAVE_GOBJECT)' \ + HAVE_GOBJECT_PRIVATES '$(HAVE_GOBJECT_PRIVATES)' \ HAVE_GTK2 '$(HAVE_GTK2)' \ pkgdatadir '$(pkgdatadir)' \ ; } >$@.tmp diff --git a/configure.ac b/configure.ac index 89d0d85..e190000 100644 --- a/configure.ac +++ b/configure.ac @@ -41,6 +41,24 @@ dnl Dependencies for test suite DX_LIB_GLIB2([], [gobject], [HAVE_GOBJECT=true], [HAVE_GOBJECT=false]) AC_SUBST([HAVE_GOBJECT]) +AS_IF([$HAVE_GOBJECT], + [AC_CACHE_CHECK([whether libgobject supports private data members], + [dx_cv_libgobject_privates], +[save_CFLAGS=$CFLAGS +CFLAGS="$CFLAGS $LIBGOBJECT_CFLAGS" +AC_COMPILE_IFELSE([AC_LANG_SOURCE( +[#include +#if defined(G_ADD_PRIVATE) || defined(G_TYPE_INSTANCE_GET_PRIVATE) +#else +DX_LIB_COMPILE_ERROR([private members not supported]) +#endif +])], [dx_cv_libgobject_privates=yes], [dx_cv_libgobject_privates=no]) +CFLAGS=$save_CFLAGS])]) + +AS_IF([test x"$dx_cv_libgobject_privates" = x"yes"], + [HAVE_GOBJECT_PRIVATES=true], [HAVE_GOBJECT_PRIVATES=false]) +AC_SUBST([HAVE_GOBJECT_PRIVATES]) + DX_LIB_GTK2([], [HAVE_GTK2=true], [HAVE_GTK2=false]) AC_SUBST([HAVE_GTK2]) diff --git a/tests/general.at b/tests/general.at index a36e4df..d7be502 100644 --- a/tests/general.at +++ b/tests/general.at @@ -1,4 +1,4 @@ -dnl Copyright © 2019-2020 Nick Bowler +dnl Copyright © 2019-2021 Nick Bowler dnl License GPLv2+: GNU General Public License version 2 or any later version. dnl This is free software: you are free to change and redistribute it. dnl There is NO WARRANTY, to the extent permitted by law. @@ -46,6 +46,7 @@ int main(void) str_gob=$abs_top_srcdir/t/str.gob AT_CHECK([gob2 "$str_gob"]) +AT_CHECK([$HAVE_GOBJECT_PRIVATES || exit 77]) TEST_COMPILE_GOBJECT([str.c], [0], [], [stderr]) mv stderr str_stderr @@ -223,6 +224,7 @@ class :Test from G:Object } ]]) AT_CHECK([gob2 test.gob]) +AT_CHECK([$HAVE_GOBJECT_PRIVATES || exit 77]) TEST_COMPILE_GOBJECT([test.c], [0], [], [ignore]) AT_DATA([main.c], [[#include @@ -263,6 +265,7 @@ class :Test from G:Object (dynamic) } ]]) AT_CHECK([gob2 test.gob]) +AT_CHECK([$HAVE_GOBJECT_PRIVATES || exit 77]) TEST_COMPILE_GOBJECT([test.c], [0], [], [ignore]) TEST_TYPE_MODULE([:Test])