Commit c57798fc authored by Denis Bilenko's avatar Denis Bilenko

testrunner.py: split spawn_subprocesses in 2 functions

parent aed40b50
...@@ -45,6 +45,7 @@ import sys ...@@ -45,6 +45,7 @@ import sys
import os import os
import glob import glob
import re import re
import traceback
from unittest import _TextTestResult, defaultTestLoader, TextTestRunner from unittest import _TextTestResult, defaultTestLoader, TextTestRunner
import platform import platform
...@@ -273,13 +274,8 @@ def run_subprocess(arg, options): ...@@ -273,13 +274,8 @@ def run_subprocess(arg, options):
return retcode[0], output return retcode[0], output
def spawn_subprocesses(options, args): def spawn_subprocess(arg, options):
if not args: success = False
args = glob.glob('test_*.py')
args.remove('test_support.py')
fail = False
uname = platform.uname()[0]
for arg in args:
if options.db: if options.db:
module_name = arg module_name = arg
if module_name.endswith('.py'): if module_name.endswith('.py'):
...@@ -292,7 +288,7 @@ def spawn_subprocesses(options, args): ...@@ -292,7 +288,7 @@ def spawn_subprocesses(options, args):
'changeset': get_changeset(), 'changeset': get_changeset(),
'libevent_version': get_libevent_version(), 'libevent_version': get_libevent_version(),
'libevent_method': get_libevent_method(), 'libevent_method': get_libevent_method(),
'uname': uname, 'uname': options.uname,
'retcode': 'TIMEOUT'} 'retcode': 'TIMEOUT'}
row_id = store_record(options.db, 'test', params) row_id = store_record(options.db, 'test', params)
params['id'] = row_id params['id'] = row_id
...@@ -302,27 +298,43 @@ def spawn_subprocesses(options, args): ...@@ -302,27 +298,43 @@ def spawn_subprocesses(options, args):
if retcode: if retcode:
sys.stdout.write(output) sys.stdout.write(output)
print '%s failed with code %s' % (arg, retcode) print '%s failed with code %s' % (arg, retcode)
fail = True
elif retcode == 0: elif retcode == 0:
if options.verbosity == 1: # // if verbosity is 2 then output is always printed by run_subprocess if options.verbosity == 1: # // if verbosity is 2 then output is always printed by run_subprocess
sys.stdout.write(output) sys.stdout.write(output)
print '%s passed' % arg print '%s passed' % arg
success = True
else: else:
print '%s timed out' % arg print '%s timed out' % arg
fail = True
if options.db: if options.db:
params['output'] = output params['output'] = output
params['retcode'] = retcode params['retcode'] = retcode
store_record(options.db, 'test', params) store_record(options.db, 'test', params)
return success
def spawn_subprocesses(options, args):
success = True
if not args:
args = glob.glob('test_*.py')
args.remove('test_support.py')
options.uname = platform.uname()[0]
for arg in args:
try:
success = spawn_subprocess(arg, options) and success
except Exception:
try:
traceback.print_exc()
except Exception:
pass
if options.db: if options.db:
try: try:
print '-' * 80 print '-' * 80
if print_stats(options): if print_stats(options):
fail = True success = False
except sqlite3.OperationalError, ex: except sqlite3.OperationalError, ex:
print ex print ex
print 'To view stats again for this run, use %s --stats --runid %s --db %s' % (sys.argv[0], options.runid, options.db) print 'To view stats again for this run, use %s --stats --runid %s --db %s' % (sys.argv[0], options.runid, options.db)
if fail: if not success:
sys.exit(1) sys.exit(1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment