summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac13
-rw-r--r--tests/Makefile.am34
-rw-r--r--tests/test-ot-tags.c8
-rw-r--r--tests/testboundaries.c26
-rw-r--r--tests/testboundaries_ucd.c65
-rw-r--r--tests/testcolor.c23
-rw-r--r--tests/testiter.c17
-rw-r--r--tests/testscript.c6
8 files changed, 133 insertions, 59 deletions
diff --git a/configure.ac b/configure.ac
index 358a428a..3453613c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@ dnl
dnl The triplet
m4_define([pango_version_major], [1])
m4_define([pango_version_minor], [34])
-m4_define([pango_version_micro], [0])
+m4_define([pango_version_micro], [1])
m4_define([pango_version],
[pango_version_major.pango_version_minor.pango_version_micro])
@@ -678,6 +678,17 @@ if test "x${enable_Bsymbolic}" = "xyes"; then
fi
dnl ********************************************************
+dnl * Installed test *
+dnl ********************************************************
+
+AC_ARG_ENABLE(installed_tests,
+ AS_HELP_STRING([--enable-installed-tests],
+ [Install test programs (default: no)]),,
+ [enable_installed_tests=no])
+AM_CONDITIONAL(BUILDOPT_INSTALL_TESTS, test x$enable_installed_tests = xyes)
+
+
+dnl ********************************************************
dnl * See whether we need to load our modules as .la files *
dnl ********************************************************
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b397beb2..f8fec40b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -7,7 +7,7 @@ EXTRA_DIST = \
CLEANFILES = pangorc
DISTCLEANFILES = all-unicode.txt
-INCLUDES = \
+AM_CPPFLAGS = \
-I$(top_srcdir) \
$(PANGO_DEBUG_FLAGS) \
$(GLIB_CFLAGS) \
@@ -17,23 +17,23 @@ INCLUDES = \
$(X_CFLAGS)
if HAVE_XFT
-INCLUDES += -DHAVE_X
+AM_CPPFLAGS += -DHAVE_X
endif
if HAVE_XFT
-INCLUDES += -DHAVE_XFT
+AM_CPPFLAGS += -DHAVE_XFT
endif
if HAVE_FREETYPE
-INCLUDES += -DHAVE_FREETYPE
+AM_CPPFLAGS += -DHAVE_FREETYPE
endif
if HAVE_WIN32
-INCLUDES += -DHAVE_WIN32
+AM_CPPFLAGS += -DHAVE_WIN32
endif
if CROSS_COMPILING
-TESTS=
+TESTS =
else
-TESTS=$(check_PROGRAMS)
+TESTS = $(check_PROGRAMS)
endif
TESTS_ENVIRONMENT = \
@@ -78,4 +78,24 @@ $(noinst_PROGRAMS) $(check_PROGRAMS): pangorc
noinst_PROGRAMS = $(check_PROGRAMS) gen-all-unicode dump-boundaries
+if BUILDOPT_INSTALL_TESTS
+insttestdir=$(pkglibexecdir)/installed-tests
+insttest_PROGRAMS = $(check_PROGRAMS)
+
+testdatadir = $(insttestdir)
+testdata_DATA = \
+ all-unicode.txt \
+ boundaries.utf8 \
+ GraphemeBreakTest.txt
+
+testmetadir = $(datadir)/installed-tests/$(PACKAGE)
+testmeta_DATA = $(check_PROGRAMS:=.test)
+
+%.test: %$(EXEEXT) Makefile
+ $(AM_V_GEN) (echo '[Test]' > $@.tmp; \
+ echo 'Type=session' >> $@.tmp; \
+ echo 'Exec=$(pkglibexecdir)/installed-tests/$<' >> $@.tmp; \
+ mv $@.tmp $@)
+endif
+
-include $(top_srcdir)/git.mk
diff --git a/tests/test-ot-tags.c b/tests/test-ot-tags.c
index 48bb47b2..9ae748c1 100644
--- a/tests/test-ot-tags.c
+++ b/tests/test-ot-tags.c
@@ -124,12 +124,12 @@ test_language_tags (void)
int
main (int argc, char **argv)
{
- g_setenv ("PANGO_RC_FILE", "./pangorc", TRUE);
+ g_test_init (&argc, &argv, NULL);
- test_script_tags ();
- test_language_tags ();
+ g_test_add_func ("/tags/script", test_script_tags);
+ g_test_add_func ("/tags/language", test_language_tags);
- return 0;
+ return g_test_run ();
}
G_GNUC_END_IGNORE_DEPRECATIONS
diff --git a/tests/testboundaries.c b/tests/testboundaries.c
index 6f860bac..241e6859 100644
--- a/tests/testboundaries.c
+++ b/tests/testboundaries.c
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <unistd.h>
+#include <glib.h>
#include <pango/pango.h>
#define CHFORMAT "%0#6x"
@@ -311,20 +312,13 @@ check_invariants (const char *text)
g_free (attrs);
}
-int
-main (int argc, char *argv[])
+static void
+test_boundaries (void)
{
gchar *text;
- const gchar *srcdir;
const gchar *filename;
-
- g_setenv ("PANGO_RC_FILE", "./pangorc", TRUE);
-
- srcdir = getenv ("srcdir");
- if (!srcdir)
- srcdir = ".";
-
- filename = g_strdup_printf ("%s/boundaries.utf8", srcdir);
+ filename = g_test_get_filename (G_TEST_DIST, "boundaries.utf8", NULL);
+ g_print ("sample file: %s\n", filename);
if (!g_file_get_contents (filename, &text, NULL, NULL))
fail ("Couldn't open sample text file");
@@ -334,7 +328,15 @@ main (int argc, char *argv[])
g_free (text);
printf ("testboundaries passed\n");
+}
+
+int
+main (int argc, char *argv[])
+{
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/text/boundaries", test_boundaries);
- return 0;
+ return g_test_run ();
}
diff --git a/tests/testboundaries_ucd.c b/tests/testboundaries_ucd.c
index e7f742b3..d9019c63 100644
--- a/tests/testboundaries_ucd.c
+++ b/tests/testboundaries_ucd.c
@@ -215,7 +215,7 @@ make_test_string (gchar *string,
}
static void
-do_test (gchar *filename,
+do_test (const gchar *filename,
AttrBits bits,
gboolean fixup_broken_linebreaktest)
{
@@ -322,43 +322,72 @@ done:
g_io_channel_unref (channel);
if (error)
g_error_free (error);
- g_free (filename);
+
+ g_assert (!failed);
}
-gint
-main (gint argc,
- gchar **argv)
+static void
+test_grapheme_break (void)
{
- gchar *srcdir;
- gchar *filename;
+ const gchar *filename;
AttrBits bits;
- setlocale (LC_ALL, "");
-
- srcdir = getenv ("srcdir");
- if (!srcdir)
- srcdir = ".";
-
- filename = g_strdup_printf ("%s/GraphemeBreakTest.txt", srcdir);
+ filename = g_test_get_filename (G_TEST_DIST, "GraphemeBreakTest.txt", NULL);
bits.bits = 0;
bits.attr.is_cursor_position = 1;
do_test (filename, bits, FALSE);
+}
- filename = g_strdup_printf ("%s/WordBreakTest.txt", srcdir);
+static void
+test_word_break (void)
+{
+ const gchar *filename;
+ AttrBits bits;
+
+ filename = g_test_get_filename (G_TEST_DIST, "WordBreakTest.txt", NULL);
bits.bits = 0;
bits.attr.is_word_boundary = 1;
do_test (filename, bits, FALSE);
+}
- filename = g_strdup_printf ("%s/SentenceBreakTest.txt", srcdir);
+static void
+test_sentence_break (void)
+{
+ const gchar *filename;
+ AttrBits bits;
+
+ filename = g_test_get_filename (G_TEST_DIST, "SentenceBreakTest.txt", NULL);
bits.bits = 0;
bits.attr.is_sentence_boundary = 1;
do_test (filename, bits, FALSE);
+}
+
+static void
+test_line_break (void)
+{
+ const gchar *filename;
+ AttrBits bits;
- filename = g_strdup_printf ("%s/LineBreakTest.txt", srcdir);
+ filename = g_test_get_filename (G_TEST_DIST, "LineBreakTest.txt", NULL);
bits.bits = 0;
bits.attr.is_line_break = 1;
bits.attr.is_mandatory_break = 1;
do_test (filename, bits, TRUE);
+}
+
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+ setlocale (LC_ALL, "");
+
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/text/break/grapheme", test_grapheme_break);
+ g_test_add_func ("/text/break/word", test_word_break);
+ g_test_add_func ("/text/break/sentence", test_sentence_break);
+ g_test_add_func ("/text/break/line", test_line_break);
- exit (failed);
+ return g_test_run ();
}
diff --git a/tests/testcolor.c b/tests/testcolor.c
index 1995d3d6..36f2dbf3 100644
--- a/tests/testcolor.c
+++ b/tests/testcolor.c
@@ -30,7 +30,7 @@ typedef struct _ColorSpec {
guint16 blue;
} ColorSpec;
-static gboolean test_color (ColorSpec *spec)
+static gboolean test_one_color (ColorSpec *spec)
{
PangoColor color;
gboolean accepted;
@@ -78,17 +78,22 @@ ColorSpec specs [] = {
{ NULL, 0, 0, 0, 0 }
};
-int
-main (int argc, char *argv[])
+static void
+test_color (void)
{
- gboolean success;
ColorSpec *spec;
- g_setenv ("PANGO_RC_FILE", "./pangorc", TRUE);
-
- success = TRUE;
for (spec = specs; spec->spec; spec++)
- success &= test_color (spec);
+ g_assert (test_one_color (spec));
+
+}
+
+int
+main (int argc, char *argv[])
+{
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/color/parse", test_color);
- return !success;
+ return g_test_run ();
}
diff --git a/tests/testiter.c b/tests/testiter.c
index 1870ce6e..773e4bc0 100644
--- a/tests/testiter.c
+++ b/tests/testiter.c
@@ -207,16 +207,14 @@ iter_cluster_test (PangoLayout *layout)
pango_layout_iter_free (iter);
}
-int
-main (int argc, char *argv[])
+static void
+test_layout_iter (void)
{
const char **ptext;
PangoFontMap *fontmap;
PangoContext *context;
PangoLayout *layout;
- g_setenv ("PANGO_RC_FILE", "./pangorc", TRUE);
-
fontmap = pango_cairo_font_map_get_default ();
context = pango_font_map_create_context (fontmap);
@@ -236,5 +234,14 @@ main (int argc, char *argv[])
}
g_object_unref (layout);
- return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/layout/iter", test_layout_iter);
+
+ return g_test_run ();
}
diff --git a/tests/testscript.c b/tests/testscript.c
index 4106e9a3..aa610b44 100644
--- a/tests/testscript.c
+++ b/tests/testscript.c
@@ -222,9 +222,9 @@ test_script_iter (void)
int
main (int argc, char **argv)
{
- g_setenv ("PANGO_RC_FILE", "./pangorc", TRUE);
+ g_test_init (&argc, &argv, NULL);
- test_script_iter ();
+ g_test_add_func ("/script/iter", test_script_iter);
- return 0;
+ return g_test_run ();
}