File: run_tests.in

package info (click to toggle)
ibus-typing-booster 2.10.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 87,788 kB
  • sloc: xml: 799,041; python: 22,939; sh: 3,519; makefile: 342
file content (62 lines) | stat: -rw-r--r-- 2,064 bytes parent folder | download | duplicates (3)
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
#!@PYTHON_BIN@

# ibus-typing-booster - A completion input method for IBus
#
# Copyright (c) 2016 Mike FABIAN <mfabian@redhat.com>
#
# 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 3 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, see <http://www.gnu.org/licenses/>

import sys
import os
import unittest

# pip3 install tap.py --user
IMPORT_TAP_SUCCESSFUL = False
try:
    from tap import TAPTestRunner
    IMPORT_TAP_SUCCESSFUL = True
except (ImportError,):
    pass

if 'IBUS_TYPING_BOOSTER_LOCATION' in os.environ:
    location_path = os.environ['IBUS_TYPING_BOOSTER_LOCATION']
    if location_path != None and location_path != '':
        engine_path = os.path.join(location_path, 'engine')
        sys.path.append(engine_path)
sys.path.append('@PKGDATADIR@/engine')

# -- Load and run our unit tests ---------------------------------------------
pattern = 'test*.py'
start_dir = os.path.dirname(__file__)
if len(sys.argv) > 1:
    pattern = sys.argv[-1]
    dir = os.path.dirname(pattern)
    pattern = os.path.basename(pattern)
    if dir != '.':
        start_dir = os.path.join(start_dir, dir)
loader = unittest.TestLoader()
suite = loader.discover(start_dir=start_dir, pattern=pattern)

if IMPORT_TAP_SUCCESSFUL:
    runner = TAPTestRunner(stream=sys.stderr, verbosity=255)
    runner.set_outdir('.')
    runner.set_format('Hi: {method_name} - {short_description}')
    runner.set_combined(True)
else:
    runner = unittest.TextTestRunner(stream=sys.stderr, verbosity=255)

result = runner.run(suite)

if result.failures or result.errors:
    sys.exit(1)