[Android] Update gtest test list parsing.

Some versions of gtest print type- and value-parameterized tests with
their respective parameter as a comment after the test name when listing
tests. This patch should allow the android test runner scripts to
correctly ignore these comments.

BUG=

Review URL: https://codereview.chromium.org/441783002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287548 0039d316-1c4b-4281-b951-d872f2087c98
parent f8c79e61
...@@ -60,7 +60,9 @@ def CommonChecks(input_api, output_api): ...@@ -60,7 +60,9 @@ def CommonChecks(input_api, output_api):
input_api, input_api,
output_api, output_api,
unit_tests=[ unit_tests=[
J('pylib', 'device', 'device_utils_test.py'),], J('pylib', 'device', 'device_utils_test.py'),
J('pylib', 'gtest', 'test_package_test.py'),
],
env=pylib_test_env)) env=pylib_test_env))
output.extend(_CheckDeletionsOnlyFiles(input_api, output_api)) output.extend(_CheckDeletionsOnlyFiles(input_api, output_api))
return output return output
......
...@@ -96,6 +96,6 @@ class TestPackage(object): ...@@ -96,6 +96,6 @@ class TestPackage(object):
continue continue
if 'YOU HAVE' in test: if 'YOU HAVE' in test:
break break
test_name = test[2:] test_name = test.split(None, 1)[0]
ret += [current + test_name] ret += [current + test_name]
return ret return ret
#!/usr/bin/env python
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import unittest
from pylib.gtest import test_package
# pylint: disable=W0212
class TestPackageTest(unittest.TestCase):
def testParseGTestListTests_simple(self):
raw_output = [
'TestCaseOne.',
' testOne',
' testTwo',
'TestCaseTwo.',
' testThree',
' testFour',
]
actual = test_package.TestPackage._ParseGTestListTests(raw_output)
expected = [
'TestCaseOne.testOne',
'TestCaseOne.testTwo',
'TestCaseTwo.testThree',
'TestCaseTwo.testFour',
]
self.assertEqual(expected, actual)
def testParseGTestListTests_parameterized_old(self):
raw_output = [
'PTestCase.',
' testWithValueParam/0',
' testWithValueParam/1',
]
actual = test_package.TestPackage._ParseGTestListTests(raw_output)
expected = [
'PTestCase.testWithValueParam/0',
'PTestCase.testWithValueParam/1',
]
self.assertEqual(expected, actual)
def testParseGTestListTests_parameterized_new(self):
raw_output = [
'PTestCase.',
' testWithValueParam/0 # GetParam() = 0',
' testWithValueParam/1 # GetParam() = 1',
]
actual = test_package.TestPackage._ParseGTestListTests(raw_output)
expected = [
'PTestCase.testWithValueParam/0',
'PTestCase.testWithValueParam/1',
]
self.assertEqual(expected, actual)
if __name__ == '__main__':
unittest.main(verbosity=2)
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