WarnLib: New library for testing API that emits warnings
authorColin Walters <walters@verbum.org>
Sun, 2 Dec 2012 17:15:53 +0000 (12:15 -0500)
committerColin Walters <walters@verbum.org>
Sun, 2 Dec 2012 21:25:02 +0000 (16:25 -0500)
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

tests/scanner/Makefile.am
tests/scanner/regress.c
tests/scanner/warnlib.c [new file with mode: 0644]
tests/scanner/warnlib.h [new file with mode: 0644]

index 9692355..01c4ea5 100644 (file)
@@ -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
index b7526bf..27791d7 100644 (file)
@@ -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 (file)
index 0000000..4fc8515
--- /dev/null
@@ -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 (file)
index 0000000..8aca901
--- /dev/null
@@ -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