Skip to content

Commit

Permalink
src/tests: Install IBus tests into gnome-desktop-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiwarat committed Jul 12, 2019
1 parent 6bdc692 commit af00f41
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 5 deletions.
13 changes: 13 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
])

39 changes: 38 additions & 1 deletion src/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 23 additions & 0 deletions src/tests/ibus-compose-locales.in
Original file line number Diff line number Diff line change
@@ -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

10 changes: 8 additions & 2 deletions src/tests/ibus-compose.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 (".");
Expand Down
4 changes: 4 additions & 0 deletions src/tests/meta.test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Test]
Type=session
Exec=@TEST_EXEC@ --tap
Output=TAP
4 changes: 2 additions & 2 deletions src/tests/runtest
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit af00f41

Please sign in to comment.