summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfujiwarat <takao.fujiwara1@gmail.com>2017-11-23 17:42:36 +0900
committerfujiwarat <takao.fujiwara1@gmail.com>2017-11-23 17:42:36 +0900
commit6d843d0505b31a622a69d318e8f4a62eea398b80 (patch)
tree3490d347f192a5a80a96008b000dfd1895e20c9f
parentec02cbdf6a61996ce1c1a5112bd16d316d266632 (diff)
downloadibus-anthy-6d843d0505b31a622a69d318e8f4a62eea398b80.tar.gz
tests: Enabled make tests
-rw-r--r--configure.ac1
-rw-r--r--tests/Makefile.am24
-rw-r--r--tests/anthycases.py5
-rw-r--r--tests/anthytest.py25
4 files changed, 52 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index d2092c9..9c23d7f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -434,6 +434,7 @@ engine/python3/default.xml.in
setup/Makefile
setup/python2/Makefile
setup/python3/Makefile
+tests/Makefile
icons/Makefile
m4/Makefile
])
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3ea659c..9d29f42 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -19,6 +19,30 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+tests:
+ ARGS="--exit"; \
+ if test x$(FORCE_TEST) != x ; then \
+ ARGS="$$ARGS --force"; \
+ fi; \
+ ibus-daemon --daemonize --verbose; \
+ sleep 1; \
+ ps -ef | grep $$USER | grep ibus | grep -v grep; \
+ echo "#### Starting Python3 API test $$ARGS"; \
+ env IBUS_ANTHY_ENGINE_PATH=../engine/python3 \
+ IBUS_ANTHY_SETUP_PATH=../setup/python3 \
+ python3 anthytest.py $$ARGS; \
+ if test $$? -ne 0 ; then \
+ exit -1; \
+ fi; \
+ if test x$(FORCE_TEST) = x ; then \
+ rm -r $$HOME/.anthy; \
+ fi; \
+ echo "#### Starting Python2 API test"; \
+ env IBUS_ANTHY_ENGINE_PATH=../engine/python2 \
+ IBUS_ANTHY_SETUP_PATH=../setup/python2 \
+ python2 anthytest.py $$ARGS;
+ ibus exit
+
EXTRA_DIST = \
anthycases.py \
anthytest.py \
diff --git a/tests/anthycases.py b/tests/anthycases.py
index 1c43d02..0f43b03 100644
--- a/tests/anthycases.py
+++ b/tests/anthycases.py
@@ -25,6 +25,11 @@ TestCases = {
'commit': { 'keys': [[IBus.KEY_Return, 0, 0]] },
'result': { 'string': '私の名前は、ペンです。' }
},
+ { 'preedit': { 'string': 'toukyou' },
+ 'conversion': { 'string': ' ' },
+ 'commit': { 'keys': [[IBus.KEY_Return, 0, 0]] },
+ 'result': { 'string': '東京' }
+ },
{ 'preedit': { 'string': 'toukyo' },
'conversion': { 'keys': [[IBus.KEY_Tab, 0, 0],
[IBus.KEY_Tab, 0, 0],
diff --git a/tests/anthytest.py b/tests/anthytest.py
index 18e9b6b..1d282f2 100644
--- a/tests/anthytest.py
+++ b/tests/anthytest.py
@@ -263,12 +263,24 @@ class AnthyTest:
def print_help(out, v = 0):
print('-e, --exit Exit this program after test is done.',
file=out)
+ print('-f, --force Run this program forcibly with .anthy.',
+ file=out)
print('-h, --help show this message.', file=out)
sys.exit(v)
+def get_userhome():
+ if 'HOME' not in os.environ:
+ import pwd
+ userhome = pwd.getpwuid(os.getuid()).pw_dir
+ else:
+ userhome = os.environ['HOME']
+ userhome = userhome.rstrip('/')
+ return userhome
+
def main():
- shortopt = 'e'
- longopt = ['exit']
+ shortopt = 'ef'
+ longopt = ['exit', 'force']
+ force_run = False
try:
opts, args = getopt.getopt(sys.argv[1:], shortopt, longopt)
except getopt.GetoptError as err:
@@ -278,13 +290,20 @@ def main():
if o in ('-e', '--exit'):
global DONE_EXIT
DONE_EXIT = True
+ elif o in ('-f', '--force'):
+ force_run = True
else:
print('Unknown argument: %s' % o, file=sys.stderr)
print_help(sys.stderr, 1)
+ anthy_user_dir = get_userhome() + '/.anthy'
+ if os.path.exists(anthy_user_dir) and not force_run:
+ print('Please remove %s before the test' % anthy_user_dir,
+ file=sys.stderr)
+ sys.exit(-1)
EngineTest = AnthyTest()
if not EngineTest.register_ibus_engine():
- return -1;
+ sys.exit(-1)
EngineTest.create_window()
EngineTest.run()