diff --git a/android/pylib/gtest/gtest_test_instance.py b/android/pylib/gtest/gtest_test_instance.py index 904f90981..49d489205 100644 --- a/android/pylib/gtest/gtest_test_instance.py +++ b/android/pylib/gtest/gtest_test_instance.py @@ -83,8 +83,14 @@ _RE_TEST_STATUS = re.compile( r'\[ +((?:RUN)|(?:FAILED)|(?:OK)|(?:CRASHED)) +\] ?' # Test name. r'([^ ]+)?' - # Optional test parameter. - r'(?:, where GetParam\(\) = [^()]*)?' + # Optional parameters. + r'(?:, where' + # Type parameter + r'(?: TypeParam = [^()]*(?: and)?)?' + # Value parameter + r'(?: GetParam\(\) = [^()]*)?' + # End of optional parameters. + ')?' # Optional test execution time. r'(?: \((\d+) ms\))?$') # Crash detection constants. diff --git a/android/pylib/gtest/gtest_test_instance_test.py b/android/pylib/gtest/gtest_test_instance_test.py index b39ac153a..b1a74dc64 100755 --- a/android/pylib/gtest/gtest_test_instance_test.py +++ b/android/pylib/gtest/gtest_test_instance_test.py @@ -177,7 +177,18 @@ class GtestTestInstanceTests(unittest.TestCase): self.assertEquals(1, actual[0].GetDuration()) self.assertEquals(base_test_result.ResultType.PASS, actual[0].GetType()) - def testParseGTestOutput_parameterized(self): + def testParseGTestOutput_typeParameterized(self): + raw_output = [ + '[ RUN ] Baz/FooTest.Bar/0', + '[ FAILED ] Baz/FooTest.Bar/0, where TypeParam = (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 testParseGTestOutput_valueParameterized(self): raw_output = [ '[ RUN ] Baz/FooTest.Bar/0', '[ FAILED ] Baz/FooTest.Bar/0,' + @@ -189,6 +200,18 @@ class GtestTestInstanceTests(unittest.TestCase): self.assertEquals(1, actual[0].GetDuration()) self.assertEquals(base_test_result.ResultType.FAIL, actual[0].GetType()) + def testParseGTestOutput_typeAndValueParameterized(self): + raw_output = [ + '[ RUN ] Baz/FooTest.Bar/0', + '[ FAILED ] Baz/FooTest.Bar/0,' + + ' where TypeParam = and GetParam() = (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)