From af00f4156b5c79c526eab18c49da80affd41ebee Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Fri, 12 Jul 2019 21:12:38 +0900 Subject: [PATCH] src/tests: Install IBus tests into gnome-desktop-testing --- configure.ac | 13 +++++++++++ src/tests/Makefile.am | 39 ++++++++++++++++++++++++++++++- src/tests/ibus-compose-locales.in | 23 ++++++++++++++++++ src/tests/ibus-compose.c | 10 ++++++-- src/tests/meta.test.in | 4 ++++ src/tests/runtest | 4 ++-- 6 files changed, 88 insertions(+), 5 deletions(-) create mode 100755 src/tests/ibus-compose-locales.in create mode 100644 src/tests/meta.test.in diff --git a/configure.ac b/configure.ac index b5a87b56b..f1df3ac1b 100644 --- a/configure.ac +++ b/configure.ac @@ -595,6 +595,18 @@ PKG_CHECK_MODULES(XTEST, ) AM_CONDITIONAL([ENABLE_XTEST], [test x"$enable_xtest" = x"yes"]) +# --enable-install-tests +AC_ARG_ENABLE(install-tests, + AS_HELP_STRING([--enable-install-tests], + [Enable to install tests]), + [enable_install_tests=$enableval], + [enable_install_tests=no] +) +AM_CONDITIONAL([ENABLE_INSTALL_TESTS], [test x"$enable_install_tests" = x"yes"]) +if test x"$enable_install_tests" = x"no"; then + enable_install_tests="no (disabled, use --enable-install-tests to enable)" +fi + # --disable-emoji-dict option. AC_ARG_ENABLE(emoji-dict, @@ -773,5 +785,6 @@ Build options: Enable Unicode dict $enable_unicode_dict UCD directory $UCD_DIR Run test cases $enable_tests + Install tests $enable_install_tests ]) diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am index a58504a35..ff31111b0 100644 --- a/src/tests/Makefile.am +++ b/src/tests/Makefile.am @@ -78,7 +78,44 @@ TESTS_ENVIRONMENT = \ LOG_COMPILER = $(srcdir)/runtest -EXTRA_DIST = runtest ibus-compose.emoji ibus-compose.env +if ENABLE_INSTALL_TESTS +test_metas_in = meta.test.in +test_execs = $(TESTS:ibus-compose=ibus-compose-locales) +test_metas = $(addsuffix .test, $(test_execs)) +test_sources_DATA = \ + $(test_metas) \ + ibus-compose.emoji \ + ibus-compose.env \ + $(NULL) +test_sourcesdir = $(datadir)/installed-tests/ibus + +test_execs_PROGRAMS = $(TESTS) +if ENABLE_GTK3 +test_execs_SCRIPTS = ibus-compose-locales +endif +test_execsdir = $(libexecdir)/installed-tests/ibus +endif + +$(test_metas): $(test_metas_in) $(test_programs) + f=`echo $@ | sed -e 's/\.test//'`; \ + TEST_EXEC=$(test_execsdir)/$$f; \ + sed -e "s|@TEST_EXEC[@]|$$TEST_EXEC|g" $(test_metas_in) > $@.tmp; \ + mv $@.tmp $@; \ + $(NULL) + +ibus-compose-locales: ibus-compose-locales.in + SRCDIR=$(test_sourcesdir); \ + sed -e "s|@SRCDIR[@]|$$SRCDIR|g" $< > $@.tmp; \ + mv $@.tmp $@; \ + $(NULL) + +EXTRA_DIST = \ + $(test_metas_in) \ + runtest \ + ibus-compose.emoji \ + ibus-compose.env \ + ibus-compose-locales.in \ + $(NULL) ibus_bus_SOURCES = ibus-bus.c ibus_bus_LDADD = $(prog_ldadd) diff --git a/src/tests/ibus-compose-locales.in b/src/tests/ibus-compose-locales.in new file mode 100755 index 000000000..8d2384d1d --- /dev/null +++ b/src/tests/ibus-compose-locales.in @@ -0,0 +1,23 @@ +#!/bin/sh + +SRCDIR=@SRCDIR@ +BUILDDIR=`dirname $0` + + +export IBUS_COMPOSE_CACHE_DIR=$PWD + +for var in `cat $SRCDIR/ibus-compose.env` +do + IS_COMMENT=`echo "$var" | grep "^#"` + if [ "x$IS_COMMENT" != x ] ; then + continue + fi + env $var $BUILDDIR/ibus-compose $SRCDIR $@ + + CACHE_FILES=`ls *.cache` + if [ x"$CACHE_FILES" != x ] ; then + echo "Clean $CACHE_FILES" + rm $CACHE_FILES + fi +done + diff --git a/src/tests/ibus-compose.c b/src/tests/ibus-compose.c index 09c687c2a..c8d3c126c 100644 --- a/src/tests/ibus-compose.c +++ b/src/tests/ibus-compose.c @@ -264,8 +264,6 @@ window_inserted_text_cb (GtkEntryBuffer *buffer, guint index = priv->data_first[i + 1]; guint j = 0; gboolean valid_output = TRUE; - if (seq == 2) - g_print ("test\n"); for (j = 0; j < num; j++) { if (priv->data_second[index + j] != code) { valid_output = FALSE; @@ -351,6 +349,14 @@ main (int argc, char *argv[]) ibus_init (); g_test_init (&argc, &argv, NULL); + /* FIXME: + * IBusIMContext opens GtkIMContextSimple as the slave and + * GtkIMContextSimple opens the compose table on el_GR.UTF-8, and the + * multiple outputs in el_GR's compose causes a warning in gtkcomposetable + * and the warning always causes a fatal in GTest: + " "GTK+ supports to output one char only: " + */ + g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL); gtk_init (&argc, &argv); m_srcdir = argc > 1 ? g_strdup (argv[1]) : g_strdup ("."); diff --git a/src/tests/meta.test.in b/src/tests/meta.test.in new file mode 100644 index 000000000..ae2b29911 --- /dev/null +++ b/src/tests/meta.test.in @@ -0,0 +1,4 @@ +[Test] +Type=session +Exec=@TEST_EXEC@ --tap +Output=TAP diff --git a/src/tests/runtest b/src/tests/runtest index 35ccc5a0d..1fcc92830 100755 --- a/src/tests/runtest +++ b/src/tests/runtest @@ -200,7 +200,7 @@ if test -f $envfile ; then ENVS="`cat $envfile`" fi; if test x"$ENVS" = x ; then - run_test_case + run_test_case $@ else LANG_backup=$LANG i=1 @@ -212,7 +212,7 @@ else export $e echo "Run `func_basename $tst` on $e" echo "=======================" - run_test_case + run_test_case $@ echo "" i=`expr $i + 1` done