Skip to content

Commit

Permalink
android: fix parameterized gtest result parsing.
Browse files Browse the repository at this point in the history
Encountered this while working on emulator test failures. The current
logic parses parameterized test failures as UNKNOWN because of the
GetParam() portion of the log line. This CL updates and documents
the regex responsible for parsing those lines.

Change-Id: Ia4339a6c03cd928bdd46f1103f0d6964f12935d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1990474
Reviewed-by: Ben Pastene <bpastene@chromium.org>
Commit-Queue: John Budorick <jbudorick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#729427}
  • Loading branch information
jbudorick authored and Commit Bot committed Jan 8, 2020
1 parent 944dd3a commit 48d4e04
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
10 changes: 8 additions & 2 deletions build/android/pylib/gtest/gtest_test_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@
# TODO(jbudorick): Remove these once we're no longer parsing stdout to generate
# results.
_RE_TEST_STATUS = re.compile(
r'\[ +((?:RUN)|(?:FAILED)|(?:OK)|(?:CRASHED)) +\]'
r' ?([^ ]+)?(?: \((\d+) ms\))?$')
# Test state.
r'\[ +((?:RUN)|(?:FAILED)|(?:OK)|(?:CRASHED)) +\] ?'
# Test name.
r'([^ ]+)?'
# Optional test parameter.
r'(?:, where GetParam\(\) = [^()]*)?'
# Optional test execution time.
r'(?: \((\d+) ms\))?$')
# Crash detection constants.
_RE_TEST_ERROR = re.compile(r'FAILURES!!! Tests run: \d+,'
r' Failures: \d+, Errors: 1')
Expand Down
12 changes: 12 additions & 0 deletions build/android/pylib/gtest/gtest_test_instance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,18 @@ def testParseGTestOutput_deathTestCrashOk(self):
self.assertEquals(1, actual[0].GetDuration())
self.assertEquals(base_test_result.ResultType.PASS, actual[0].GetType())

def testParseGTestOutput_parameterized(self):
raw_output = [
'[ RUN ] Baz/FooTest.Bar/0',
'[ FAILED ] Baz/FooTest.Bar/0,' +
' where GetParam() = 4-byte object <00-00 00-00> (1 ms)',
]
actual = gtest_test_instance.ParseGTestOutput(raw_output, None, None)
self.assertEquals(1, len(actual))
self.assertEquals('Baz/FooTest.Bar/0', actual[0].GetName())
self.assertEquals(1, actual[0].GetDuration())
self.assertEquals(base_test_result.ResultType.FAIL, actual[0].GetType())

def testParseGTestXML_none(self):
actual = gtest_test_instance.ParseGTestXML(None)
self.assertEquals([], actual)
Expand Down

0 comments on commit 48d4e04

Please sign in to comment.