Index: build/android/pylib/test_package.py |
diff --git a/build/android/pylib/test_package.py b/build/android/pylib/test_package.py |
index 526fa99b92b3d232f6047e21d135304abc1533fa..356268d3e54d1ace6281bc862fa90dc3dbcbe159 100644 |
--- a/build/android/pylib/test_package.py |
+++ b/build/android/pylib/test_package.py |
@@ -124,39 +124,43 @@ class TestPackage(object): |
crashed_tests = [] |
timed_out = False |
overall_fail = False |
+ |
+ # Test case statuses. |
re_run = re.compile('\[ RUN \] ?(.*)\r\n') |
- # APK tests rely on the PASSED tag. |
+ re_fail = re.compile('\[ FAILED \] ?(.*)\r\n') |
craigdh
2012/12/14 23:10:47
These regexes are nearly identical.
pattern = '\[
frankf
2012/12/17 20:09:28
There are 3 different patterns, not much to gain.
craigdh
2012/12/17 20:24:09
Ok. I had only caught two when I looked before. It
|
+ re_ok = re.compile('\[ OK \] ?(.*?) .*\r\n') |
+ |
+ # Test run statuses. |
re_passed = re.compile('\[ PASSED \] ?(.*)\r\n') |
+ re_runner_fail = re.compile('\[ RUNNER_FAILED \] ?(.*)\r\n') |
# Signal handlers are installed before starting tests |
# to output the CRASHED marker when a crash happens. |
re_crash = re.compile('\[ CRASHED \](.*)\r\n') |
- re_fail = re.compile('\[ FAILED \] ?(.*)\r\n') |
- re_runner_fail = re.compile('\[ RUNNER_FAILED \] ?(.*)\r\n') |
- re_ok = re.compile('\[ OK \] ?(.*?) .*\r\n') |
+ |
try: |
while True: |
found = p.expect([re_run, re_passed, re_runner_fail], |
timeout=self.timeout) |
- if found == 1: # matched PASSED. |
+ if found == 1: # re_passed |
break |
- if found == 2: # RUNNER_FAILED |
- logging.error('RUNNER_FAILED') |
+ elif found == 2: # re_runner_fail |
overall_fail = True |
break |
- if self.dump_debug_info: |
- self.dump_debug_info.TakeScreenshot('_Test_Start_Run_') |
- full_test_name = p.match.group(1).replace('\r', '') |
- found = p.expect([re_ok, re_fail, re_crash], timeout=self.timeout) |
- if found == 0: # re_ok |
- if full_test_name == p.match.group(1).replace('\r', ''): |
- ok_tests += [BaseTestResult(full_test_name, p.before)] |
- continue |
- if found == 2: # re_crash |
- crashed_tests += [BaseTestResult(full_test_name, p.before)] |
- overall_fail = True |
- break |
- # The test failed. |
- failed_tests += [BaseTestResult(full_test_name, p.before)] |
+ else: # re_run |
+ if self.dump_debug_info: |
+ self.dump_debug_info.TakeScreenshot('_Test_Start_Run_') |
+ |
+ full_test_name = p.match.group(1).replace('\r', '') |
+ found = p.expect([re_ok, re_fail, re_crash], timeout=self.timeout) |
+ if found == 0: # re_ok |
+ if full_test_name == p.match.group(1).replace('\r', ''): |
+ ok_tests += [BaseTestResult(full_test_name, p.before)] |
+ elif found == 2: # re_crash |
+ crashed_tests += [BaseTestResult(full_test_name, p.before)] |
+ overall_fail = True |
+ break |
+ else: # re_fail |
+ failed_tests += [BaseTestResult(full_test_name, p.before)] |
except pexpect.EOF: |
logging.error('Test terminated - EOF') |
raise errors.DeviceUnresponsiveError('Device may be offline') |
@@ -169,11 +173,11 @@ class TestPackage(object): |
ret_code = self._GetGTestReturnCode() |
if ret_code: |
- failed_tests += [BaseTestResult('gtest exit code: %d' % ret_code, |
- 'pexpect.before: %s' |
- '\npexpect.after: %s' |
- % (p.before, |
- p.after))] |
+ logging.critical( |
+ 'gtest exit code: %d\npexpect.before: %s\npexpect.after: %s', |
+ ret_code, p.before, p.after) |
+ overall_fail = True |
+ |
# Create TestResults and return |
return TestResults.FromRun(ok=ok_tests, failed=failed_tests, |
crashed=crashed_tests, timed_out=timed_out, |