Skip to content

Commit

Permalink
Bug 846169: Display a message that tbpl will recognise for test timeo…
Browse files Browse the repository at this point in the history
…uts when in parseable output mode. r=ochameau

(cherry picked from commit b81ddb1)
  • Loading branch information
Wes Kocher committed Mar 4, 2013
1 parent 8c1756d commit f23a54b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions python-lib/cuddlefish/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,7 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None,
binary=options.binary,
profiledir=options.profiledir,
verbose=options.verbose,
parseable=options.parseable,
enforce_timeouts=enforce_timeouts,
logfile=options.logfile,
addons=options.addons,
Expand Down
25 changes: 20 additions & 5 deletions python-lib/cuddlefish/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
# Used to filter only messages send by `console` module
FILTER_ONLY_CONSOLE_FROM_ADB = re.compile(r'^I/(stdout|stderr)\s*\(\s*\d+\):\s*((info|warning|error|debug): .*)$')

# Used to detect the currently running test
PARSEABLE_TEST_NAME = re.compile(r'TEST-START \| ([^\n]+)\n')

# Maximum time we'll wait for tests to finish, in seconds.
# The purpose of this timeout is to recover from infinite loops. It should be
# longer than the amount of time any test run takes, including those on slow
Expand Down Expand Up @@ -401,7 +404,7 @@ def set_overloaded_modules(env_root, app_type, addon_id, preferences, overloads)

def run_app(harness_root_dir, manifest_rdf, harness_options,
app_type, binary=None, profiledir=None, verbose=False,
enforce_timeouts=False,
parseable=False, enforce_timeouts=False,
logfile=None, addons=None, args=None, extra_environment={},
norun=None,
used_files=None, enable_mobile=False,
Expand Down Expand Up @@ -704,6 +707,14 @@ def maybe_remove_outfile():

done = False
result = None
test_name = "unknown"

def Timeout(message, test_name, parseable):
if parseable:
sys.stderr.write("TEST-UNEXPECTED-FAIL | %s | %s\n" % (test_name, message))
sys.stderr.flush()
return Exception(message)

try:
while not done:
time.sleep(0.05)
Expand All @@ -714,6 +725,10 @@ def maybe_remove_outfile():
last_output_time = time.time()
sys.stderr.write(new_chars)
sys.stderr.flush()
if is_running_tests and parseable:
match = PARSEABLE_TEST_NAME.search(new_chars)
if match:
test_name = match.group(1)
if os.path.exists(resultfile):
result = open(resultfile).read()
if result:
Expand All @@ -724,11 +739,11 @@ def maybe_remove_outfile():
sys.stderr.write("'"+result+"'\n")
if enforce_timeouts:
if time.time() - last_output_time > OUTPUT_TIMEOUT:
raise Exception("Test output exceeded timeout (%ds)." %
OUTPUT_TIMEOUT)
raise Timeout("Test output exceeded timeout (%ds)." %
OUTPUT_TIMEOUT, test_name, parseable)
if time.time() - starttime > RUN_TIMEOUT:
raise Exception("Test run exceeded timeout (%ds)." %
RUN_TIMEOUT)
raise Timeout("Test run exceeded timeout (%ds)." %
RUN_TIMEOUT, test_name, parseable)
except:
runner.stop()
raise
Expand Down

0 comments on commit f23a54b

Please sign in to comment.