gajim-plural/test/runtests.py

62 lines
1.5 KiB
Python
Raw Normal View History

2016-10-10 15:22:51 +02:00
#!/usr/bin/env python3
2008-08-09 01:53:44 +02:00
'''
Runs Gajim's Test Suite
Unit tests tests will be run on each commit.
'''
import sys
2008-08-09 01:53:44 +02:00
import unittest
import getopt
use_x = True
verbose = 1
try:
shortargs = 'hnv:'
longargs = 'help no-x verbose='
opts, args = getopt.getopt(sys.argv[1:], shortargs, longargs.split())
2013-01-01 23:18:36 +01:00
except getopt.error as msg:
2013-01-01 19:36:56 +01:00
print(msg)
print('for help use --help')
sys.exit(2)
for o, a in opts:
if o in ('-h', '--help'):
2013-01-01 19:36:56 +01:00
print('runtests [--help] [--no-x] [--verbose level]')
sys.exit()
elif o in ('-n', '--no-x'):
use_x = False
elif o in ('-v', '--verbose'):
try:
verbose = int(a)
except Exception:
2013-01-01 19:36:56 +01:00
print('verbose must be a number >= 0')
sys.exit(2)
2008-08-09 01:53:44 +02:00
# new test modules need to be added manually
2013-04-07 23:41:15 +02:00
modules = ( 'unit.test_protocol_caps',
2010-08-27 11:47:38 +02:00
'unit.test_caps_cache',
'unit.test_contacts',
'unit.test_account',
)
if use_x:
2013-04-07 23:41:15 +02:00
modules += ( 'unit.test_sessions',
#'integration.test_gui_event_integration',
'integration.test_roster',
'integration.test_resolver',
2017-08-09 22:09:01 +02:00
'unit.test_gui_interface',
2010-08-27 11:47:38 +02:00
)
nb_errors = 0
nb_failures = 0
2008-08-09 01:53:44 +02:00
for mod in modules:
suite = unittest.defaultTestLoader.loadTestsFromName(mod)
result = unittest.TextTestRunner(verbosity=verbose).run(suite)
nb_errors += len(result.errors)
nb_failures += len(result.failures)
sys.exit(nb_errors + nb_failures)