Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Unified Diff: build/android/pylib/gtest/gtest_test_instance.py

Issue 2509623003: Fix KeyError caused when filtering gtests on multiple threads. (Closed)
Patch Set: Rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9cf76a277f4233fcbf546b9c54e0fad4e9597555..fe0251019a56fa28be6b14bb138f33ed615becb7 100644
--- a/build/android/pylib/gtest/gtest_test_instance.py
+++ b/build/android/pylib/gtest/gtest_test_instance.py
@@ -7,6 +7,7 @@ import logging
import os
import re
import tempfile
+import threading
import xml.etree.ElementTree
from devil.android import apk_helper
@@ -240,6 +241,7 @@ class GtestTestInstance(test_instance.TestInstance):
self._shard_timeout = args.shard_timeout
self._store_tombstones = args.store_tombstones
self._suite = args.suite_name[0]
+ self._filter_tests_lock = threading.Lock()
# GYP:
if args.executable_dist_dir:
@@ -428,10 +430,13 @@ class GtestTestInstance(test_instance.TestInstance):
gtest_filter_strings.append(self._gtest_filter)
filtered_test_list = test_list
- for gtest_filter_string in gtest_filter_strings:
- logging.debug('Filtering tests using: %s', gtest_filter_string)
- filtered_test_list = unittest_util.FilterTestNames(
- filtered_test_list, gtest_filter_string)
+ # This lock is required because on older versions of Python
+ # |unittest_util.FilterTestNames| use of |fnmatch| is not threadsafe.
+ with self._filter_tests_lock:
+ for gtest_filter_string in gtest_filter_strings:
+ logging.debug('Filtering tests using: %s', gtest_filter_string)
+ filtered_test_list = unittest_util.FilterTestNames(
+ filtered_test_list, gtest_filter_string)
return filtered_test_list
def _GenerateDisabledFilterString(self, disabled_prefixes):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698