Chromium Code Reviews| Index: build/android/pylib/gtest/gtest_test_instance.py |
| diff --git a/build/android/pylib/gtest/gtest_test_instance.py b/build/android/pylib/gtest/gtest_test_instance.py |
| index f9c6e5911b6aecf0147de3e07fd2396fbba0b624..6136ee6e130121b0efe1469a9147d933e557fbd1 100644 |
| --- a/build/android/pylib/gtest/gtest_test_instance.py |
| +++ b/build/android/pylib/gtest/gtest_test_instance.py |
| @@ -198,6 +198,24 @@ def ParseGTestXML(xml_content): |
| return results |
| +# Converts file contents described by //testing/buildbot/filters/README.md |
|
jbudorick
2016/11/03 18:21:18
Nit: make this a docstring, please.
Łukasz Anforowicz
2016/11/03 19:34:38
Ooops. Thanks for catching this. I guess I've be
|
| +# into an argument for --gtest_filter command line parameter. |
| +def ConvertTestFilterFileIntoGTestFilterArgument(input_lines): |
| + # Strip whitespace + skip empty lines and lines beginning with '#'. |
| + stripped_lines = (l.strip() for l in input_lines) |
| + filter_lines = list(l for l in stripped_lines if l and l[0] != '#') |
| + |
| + # Split the tests into positive and negative patterns (gtest treats |
| + # every pattern after the first '-' sign as an exclusion). |
| + positive_patterns = ':'.join(l for l in filter_lines if l[0] != '-') |
| + negative_patterns = ':'.join(l[1:] for l in filter_lines if l[0] == '-') |
| + if negative_patterns: |
| + negative_patterns = '-' + negative_patterns |
| + |
| + # Join the filter lines into one, big --gtest_filter argument. |
| + return positive_patterns + negative_patterns |
| + |
| + |
| class GtestTestInstance(test_instance.TestInstance): |
| def __init__(self, args, isolate_delegate, error_func): |
| @@ -252,13 +270,7 @@ class GtestTestInstance(test_instance.TestInstance): |
| self._gtest_filter = args.test_filter |
| elif args.test_filter_file: |
| with open(args.test_filter_file, 'r') as f: |
| - # Strip whitespace + skip empty lines and lines beginning with '#'. |
| - # This should be consistent with processing of |
| - # --test-launcher-filter-file in base/test/launcher/test_launcher.cc. |
| - stripped_lines = (l.strip() for l in f) |
| - filter_lines = (l for l in stripped_lines if l and l[0] != '#') |
| - # Join the filter lines into one, big --gtest_filter argument. |
| - self._gtest_filter = ':'.join(filter_lines) |
| + self._gtest_filter = ConvertTestFilterFileIntoGTestFilterArgument(f) |
| else: |
| self._gtest_filter = None |