Skip to content

Commit

Permalink
tests: Fix make check with GitHub action
Browse files Browse the repository at this point in the history
The test scripts invoke anthytest.py whose unittest can skip tests
unless Display is available and the return value has been changed
since Python 3.12.1

No pycotap.__main__ and cannot be directly executed with `-m` option.

Fedora 39 Docker does not provide USER environment variable.

Fixes: ibus@b279e15
  • Loading branch information
fujiwarat committed Jan 31, 2024
1 parent a68fa27 commit 16ba437
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
14 changes: 10 additions & 4 deletions tests/test-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ ANTHY_SCHEMA_FILE=org.freedesktop.ibus.engine.anthy.gschema.xml;
SCHEMA_TMPDIR="";
FORCE_TEST="";
RUN_ARGS="";
# Fedora 39 Docker does not provide USER
USER=${USER:-`id | sed -e "s/uid=[0-9]*(\([^)]*\)).*/\1/"`};

usage()
{
Expand Down Expand Up @@ -73,7 +75,8 @@ maybe_install_pycotap() {
fi;

# Check if pycotap is already available.
if ! python3 -m pycotap >/dev/null; then
# No pycotap.__main__ and cannot be directly executed with `-m` option
if ! python3 -c "import pycotap"; then
PIP=pip3
if ! command -v $PIP &> /dev/null ; then
PIP=pip
Expand Down Expand Up @@ -122,7 +125,8 @@ init_environment()

run_ibus_daemon()
{
ibus-daemon --daemonize --verbose --panel disable;
# this script can run without Display
ibus-daemon --daemonize --verbose --panel disable --emoji-extension disable;
sleep 1;
SUSER=`echo "$USER" | cut -c 1-7`;
ps -ef | grep "$SUSER" | grep ibus | grep -v grep;
Expand All @@ -141,8 +145,10 @@ run_test_suite()
env IBUS_ANTHY_ENGINE_PATH=$SRCDIR/../engine/python$i \
IBUS_ANTHY_SETUP_PATH=$SRCDIR/../setup/python$i \
python$i -u $SRCDIR/anthytest.py $RUN_ARGS;
if test $? -ne 0 ; then
exit -1;
RETVAL=$?
# Return 5 with "NO TESTS RAN" in unittest/runner.py since python 3.12.1
if test $RETVAL -ne 0 && test $RETVAL -ne 5; then
exit 1;
fi;
if test x$FORCE_TEST = x ; then
rm -r $HOME/.anthy;
Expand Down
8 changes: 6 additions & 2 deletions tests/test-console.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ PID_XORG=0;
PID_GNOME_SESSION=0;
FORCE_TEST="";
RUN_ARGS="--exit";
# Fedora 39 Docker does not provide USER
USER=${USER:-`id | sed -e "s/uid=[0-9]*(\([^)]*\)).*/\1/"`};

usage()
{
Expand Down Expand Up @@ -152,8 +154,10 @@ run_test_suite()
echo "#### Starting $PYTHON API test $RUN_ARGS";
export GTK_IM_MODULE=ibus
$PYTHON -u $SRCDIR/anthytest.py $RUN_ARGS;
if test $? -ne 0 ; then
exit -1;
RETVAL=$?
# Return 5 with "NO TESTS RAN" in unittest/runner.py since python 3.12.1
if test $RETVAL -ne 0 && test $RETVAL -ne 5; then
exit 1;
fi;
if test x$FORCE_TEST = x ; then
for ANTHY_CONFIG in ".anthy" ".config/anthy" ; do
Expand Down

0 comments on commit 16ba437

Please sign in to comment.