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

Side by Side Diff: build/android/pylib/base/test_dispatcher.py

Issue 153743008: Revert of Enable presubmit pylint in build/android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merging with changes to pylib/linker/test_case.py. Created 6 years, 10 months 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 unified diff | Download patch
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Dispatches tests, either sharding or replicating them. 5 """Dispatches tests, either sharding or replicating them.
6 6
7 Performs the following steps: 7 Performs the following steps:
8 * Create a test collection factory, using the given tests 8 * Create a test collection factory, using the given tests
9 - If sharding: test collection factory returns the same shared test collection 9 - If sharding: test collection factory returns the same shared test collection
10 to all test runners 10 to all test runners
11 - If replciating: test collection factory returns a unique test collection to 11 - If replciating: test collection factory returns a unique test collection to
12 each test runner, with the same set of tests in each. 12 each test runner, with the same set of tests in each.
13 * Create a test runner for each device. 13 * Create a test runner for each device.
14 * Run each test runner in its own thread, grabbing tests from the test 14 * Run each test runner in its own thread, grabbing tests from the test
15 collection until there are no tests left. 15 collection until there are no tests left.
16 """ 16 """
17 17
18 import logging 18 import logging
19 import threading 19 import threading
20 20
21 from pylib import android_commands 21 from pylib import android_commands
22 from pylib import constants 22 from pylib import constants
23 from pylib.base import base_test_result
24 from pylib.utils import reraiser_thread 23 from pylib.utils import reraiser_thread
25 from pylib.utils import watchdog_timer 24 from pylib.utils import watchdog_timer
26 25
26 import base_test_result
27
27 28
28 DEFAULT_TIMEOUT = 7 * 60 # seven minutes 29 DEFAULT_TIMEOUT = 7 * 60 # seven minutes
29 30
30 31
31 class _ThreadSafeCounter(object): 32 class _ThreadSafeCounter(object):
32 """A threadsafe counter.""" 33 """A threadsafe counter."""
33 34
34 def __init__(self): 35 def __init__(self):
35 self._lock = threading.Lock() 36 self._lock = threading.Lock()
36 self._value = 0 37 self._value = 0
(...skipping 24 matching lines...) Expand all
61 self.tries = tries 62 self.tries = tries
62 63
63 64
64 class _TestCollection(object): 65 class _TestCollection(object):
65 """A threadsafe collection of tests. 66 """A threadsafe collection of tests.
66 67
67 Args: 68 Args:
68 tests: List of tests to put in the collection. 69 tests: List of tests to put in the collection.
69 """ 70 """
70 71
71 def __init__(self, tests=None): 72 def __init__(self, tests=[]):
72 if not tests:
73 tests = []
74 self._lock = threading.Lock() 73 self._lock = threading.Lock()
75 self._tests = [] 74 self._tests = []
76 self._tests_in_progress = 0 75 self._tests_in_progress = 0
77 # Used to signal that an item is avaliable or all items have been handled. 76 # Used to signal that an item is avaliable or all items have been handled.
78 self._item_avaliable_or_all_done = threading.Event() 77 self._item_avaliable_or_all_done = threading.Event()
79 for t in tests: 78 for t in tests:
80 self.add(t) 79 self.add(t)
81 80
82 def _pop(self): 81 def _pop(self):
83 """Pop a test from the collection. 82 """Pop a test from the collection.
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 logging.info('Will run %d tests (%s): %s', len(tests), log_string, str(tests)) 357 logging.info('Will run %d tests (%s): %s', len(tests), log_string, str(tests))
359 runners = _CreateRunners(runner_factory, devices, setup_timeout) 358 runners = _CreateRunners(runner_factory, devices, setup_timeout)
360 try: 359 try:
361 return _RunAllTests(runners, test_collection_factory, 360 return _RunAllTests(runners, test_collection_factory,
362 num_retries, test_timeout, tag_results_with_device) 361 num_retries, test_timeout, tag_results_with_device)
363 finally: 362 finally:
364 try: 363 try:
365 _TearDownRunners(runners, setup_timeout) 364 _TearDownRunners(runners, setup_timeout)
366 except android_commands.errors.DeviceUnresponsiveError as e: 365 except android_commands.errors.DeviceUnresponsiveError as e:
367 logging.warning('Device unresponsive during TearDown: [%s]', e) 366 logging.warning('Device unresponsive during TearDown: [%s]', e)
OLDNEW
« no previous file with comments | « build/android/pylib/base/base_test_runner.py ('k') | build/android/pylib/base/test_dispatcher_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698