File: test-build.sh

package info (click to toggle)
ibus-anthy 1.5.10-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,608 kB
  • sloc: python: 12,805; makefile: 397; sh: 262; ansic: 256
file content (142 lines) | stat: -rw-r--r-- 4,382 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/sh
# vim:set noet ts=4:
#
# ibus-anthy - The Anthy engine for IBus
#
# Copyright (c) 2018 Takao Fujiwara <takao.fujiwara1@gmail.com>
# Copyright (c) 2018 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

# This test runs $(top_builddir)/engine/python*/engine.py before install anthy

BUILDDIR=".";
SRCDIR=".";
ANTHY_SCHEMA_FILE=org.freedesktop.ibus.engine.anthy.gschema.xml;
SCHEMA_TMPDIR="";
FORCE_TEST="";
RUN_ARGS="--exit";

usage()
{
    echo -e \
"This test runs top_builddir/engine/python*/engine.py before install anthy\n"  \
"$PROGNAME [OPTIONS…]\n"                                                       \
"\n"                                                                           \
"OPTIONS:\n"                                                                   \
"-h, --help                       This help\n"                                 \
"-v, --version                    Show version\n"                              \
"-b, --builddir=BUILDDIR          Set the BUILDDIR\n"                          \
"-s, --srcdir=SOURCEDIR           Set the SOURCEDIR\n"                         \
"-f, --force                      Run test suite forcibly\n"                   \
""
}

parse_args()
{
    # This is GNU getopt. "sudo port getopt" in BSD?
    ARGS=`getopt -o hvb:s: --long help,version,builddir:,srcdir: \
        -- "$@"`;
    eval set -- "$ARGS"
    while [ 1 ] ; do
        case "$1" in
        -h | --help )        usage; exit 0;;
        -v | --version )     echo -e "$VERSION"; exit 0;;
        -b | --builddir )    BUILDDIR="$2"; shift 2;;
        -s | --srcdir )      SRCDIR="$2"; shift 2;;
        -f | --force )       FORCE_TEST="1"; shift;;
        -- )                 shift; break;; 
        * )                  usage; exit 1;;
        esac;
    done;
}

init_environment()
{
    if test x$FORCE_TEST != x ; then
        RUN_ARGS="$RUN_ARGS --force";
    fi;
    if test ! -f $BUILDDIR/../data/$ANTHY_SCHEMA_FILE ; then
        echo "Not found $BUILDDIR/../data/$ANTHY_SCHEMA_FILE";
        exit -1;
    fi;
    SCHEMA_TMPDIR=`mktemp -d`;
    if test $? -ne 0 ; then
        echo "FAILED mktemp";
        exit -1;
    fi;
    cp $BUILDDIR/../data/$ANTHY_SCHEMA_FILE $SCHEMA_TMPDIR;
    glib-compile-schemas $SCHEMA_TMPDIR;
    if test $? -ne 0 ; then
        echo "FAILED glib-compile-schemas $SCHEMA_TMPDIR";
        exit -1;
    fi;
    if test ! -f $SCHEMA_TMPDIR/gschemas.compiled ; then
        echo "Not found $SCHEMA_TMPDIR/gschemas.compiled";
        exit -1;
    fi;
    ls $BUILDDIR/../gir/Anthy*.typelib > /dev/null;
    if test $? -ne 0 ; then
        echo "Not found $BUILDDIR/../gir/Anthy*.typelib";
        exit -1;
    fi;
}

run_ibus_daemon()
{
    ibus-daemon --daemonize --verbose;
    sleep 1;
    SUSER=`echo "$USER" | cut -c 1-7`;
    ps -ef | grep "$SUSER" | grep ibus | grep -v grep;
}

run_test_suite()
{
    export GSETTINGS_SCHEMA_DIR=$SCHEMA_TMPDIR;
    export GI_TYPELIB_PATH=$BUILDDIR/../gir;
    LD_LIBRARY_PATH=$BUILDDIR/../gir/.libs;
    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$BUILDDIR/../gir;
    export GTK_IM_MODULE=ibus;

    for i in 3 2 ; do
        echo "#### Starting Python$i API test $RUN_ARGS";
        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;
        fi;
        if test x$FORCE_TEST = x ; then
            rm -r $HOME/.anthy;
        fi;
    done;
}

finit()
{
    rm -rf $SCHEMA_TMPDIR;
    ibus exit;
}

main()
{
    parse_args $@;
    init_environment;
    run_ibus_daemon;
    run_test_suite;
    finit;
}

main $@;