summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2012-12-02 12:15:53 -0500
committerColin Walters <walters@verbum.org>2012-12-02 16:25:02 -0500
commit97b30ae5e77d5e36d127d02b247d6d41b8e1c8c3 (patch)
tree5e038984d7b6586a747b06dd2476079b68587f80 /tests
parentceb84d1e084b8048b2abb81d1e1ebe600f00d00e (diff)
downloadgobject-introspection-97b30ae5e77d5e36d127d02b247d6d41b8e1c8c3.tar.gz
WarnLib: New library for testing API that emits warnings
Both GIMarshallingTests and Regress right now use --warn-error; but in some cases (e.g. GErrors without a corresponding enum), we still want bindings to support the functionality. So add this new library where we can add C API that emits introspection warnings. https://bugzilla.gnome.org/show_bug.cgi?id=689488
Diffstat (limited to 'tests')
-rw-r--r--tests/scanner/Makefile.am14
-rw-r--r--tests/scanner/regress.c14
-rw-r--r--tests/scanner/warnlib.c20
-rw-r--r--tests/scanner/warnlib.h13
4 files changed, 60 insertions, 1 deletions
diff --git a/tests/scanner/Makefile.am b/tests/scanner/Makefile.am
index 96923550..01c4ea53 100644
--- a/tests/scanner/Makefile.am
+++ b/tests/scanner/Makefile.am
@@ -14,6 +14,7 @@ check_LTLIBRARIES = \
libgtkfrob.la \
libgettype.la \
libregress.la \
+ libwarnlib.la \
$(NULL)
AM_CPPFLAGS = -I$(top_srcdir)/girepository
@@ -36,10 +37,14 @@ libutility_la_SOURCES = $(srcdir)/utility.c $(srcdir)/utility.h
libgtkfrob_la_SOURCES = $(srcdir)/gtkfrob.c $(srcdir)/gtkfrob.h
libregress_la_SOURCES = $(srcdir)/regress.c $(srcdir)/regress.h
libregress_la_LIBADD = $(GIO_LIBS) $(CAIRO_LIBS)
+libwarnlib_la_CFLAGS = $(AM_CFLAGS)
+libwarnlib_la_SOURCES = $(srcdir)/warnlib.c $(srcdir)/warnlib.h
+libwarnlib_la_LIBADD = $(GIO_LIBS)
+libwarnlib_la_LDFLAGS = -export-symbols-regex '^warnlib_' -no-undefined
libgettype_la_SOURCES = $(srcdir)/gettype.c $(srcdir)/gettype.h
testsdir = $(datadir)/gobject-introspection-1.0/tests
-tests_DATA = $(libregress_la_SOURCES)
+tests_DATA = $(libregress_la_SOURCES) $(libwarnlib_la_SOURCES)
libregress_la_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS)
libregress_la_LDFLAGS = $(AM_LDFLAGS)
@@ -72,6 +77,13 @@ Regress_1_0_gir_FILES = $(libregress_la_SOURCES)
Regress_1_0_gir_SCANNERFLAGS = --c-include="regress.h" --warn-error
GIRS += Regress-1.0.gir
+WarnLib-1.0.gir: $(top_builddir)/Gio-2.0.gir libwarnlib.la
+WarnLib_1_0_gir_LIBS = libwarnlib.la
+WarnLib_1_0_gir_INCLUDES = Gio-2.0
+WarnLib_1_0_gir_FILES = $(libwarnlib_la_SOURCES)
+WarnLib_1_0_gir_SCANNERFLAGS = --c-include="warnlib.h"
+GIRS += WarnLib-1.0.gir
+
Annotation-1.0.gir: Utility-1.0.gir libannotation.la
Annotation_1_0_gir_PACKAGES = gobject-2.0
Annotation_1_0_gir_LIBS = libannotation.la
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c
index b7526bfb..27791d7e 100644
--- a/tests/scanner/regress.c
+++ b/tests/scanner/regress.c
@@ -1656,6 +1656,20 @@ regress_atest_error_quark (void)
return g_quark_from_static_string ("regress-atest-error");
}
+GQuark
+regress_unpaired_error_quark (void)
+{
+ return g_quark_from_static_string ("regress-unpaired-error");
+}
+
+gboolean
+regress_throw_unpaired (GError **error)
+{
+ g_set_error_literal (error, regress_unpaired_error_quark (), 0,
+ "Unpaired error");
+ return FALSE;
+}
+
/* structures */
/**
diff --git a/tests/scanner/warnlib.c b/tests/scanner/warnlib.c
new file mode 100644
index 00000000..4fc8515d
--- /dev/null
+++ b/tests/scanner/warnlib.c
@@ -0,0 +1,20 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+#include "config.h"
+
+#include "warnlib.h"
+
+GQuark
+warnlib_unpaired_error_quark (void)
+{
+ return g_quark_from_static_string ("warnlib-unpaired-error");
+}
+
+gboolean
+warnlib_throw_unpaired (GError **error)
+{
+ g_set_error_literal (error, warnlib_unpaired_error_quark (), 0,
+ "Unpaired error");
+ return FALSE;
+}
+
diff --git a/tests/scanner/warnlib.h b/tests/scanner/warnlib.h
new file mode 100644
index 00000000..8aca901a
--- /dev/null
+++ b/tests/scanner/warnlib.h
@@ -0,0 +1,13 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+#ifndef __WARNLIB_H__
+#define __WARNLIB_H__
+
+#include <gio/gio.h>
+
+#define WARNLIB_UNPAIRED_ERROR (warnlib_unpaired_error_quark ())
+GQuark warnlib_unpaired_error_quark (void);
+
+gboolean warnlib_throw_unpaired (GError **error);
+
+#endif