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

Unified Diff: build/android/pylib/base/shard_unittest.py

Issue 12378048: [Android] Switch instrumentation tests to the new shard/runner paradigm. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add retries to the end of the queue instead of the beginning Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/pylib/base/shard.py ('k') | build/android/pylib/browsertests/dispatch.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/base/shard_unittest.py
diff --git a/build/android/pylib/base/shard_unittest.py b/build/android/pylib/base/shard_unittest.py
index 79aa5b20d894be931b0d2d3b827922569837e91d..e06d98dc2e0942539087eea8e60248cd7ac9ea15 100644
--- a/build/android/pylib/base/shard_unittest.py
+++ b/build/android/pylib/base/shard_unittest.py
@@ -25,8 +25,9 @@ class TestException(Exception):
class MockRunner(object):
"""A mock TestRunner."""
- def __init__(self, device='0'):
+ def __init__(self, device='0', shard_index=0):
self.device = device
+ self.shard_index = shard_index
self.setups = 0
self.teardowns = 0
@@ -50,8 +51,8 @@ class MockRunnerFail(MockRunner):
class MockRunnerFailTwice(MockRunner):
- def __init__(self, device='0'):
- super(MockRunnerFailTwice, self).__init__(device)
+ def __init__(self, device='0', shard_index=0):
+ super(MockRunnerFailTwice, self).__init__(device, shard_index)
self._fails = 0
def RunTest(self, test):
@@ -97,10 +98,16 @@ class TestFunctions(unittest.TestCase):
def testSetUp(self):
runners = []
- shard._SetUp(MockRunner, '0', runners)
+ counter = shard._ThreadSafeCounter()
+ shard._SetUp(MockRunner, '0', runners, counter)
self.assertEqual(len(runners), 1)
self.assertEqual(runners[0].setups, 1)
+ def testThreadSafeCounter(self):
+ counter = shard._ThreadSafeCounter()
+ for i in xrange(5):
+ self.assertEqual(counter.GetAndIncrement(), i)
+
class TestThreadGroupFunctions(unittest.TestCase):
"""Tests for shard._RunAllTests and shard._CreateRunners."""
@@ -111,6 +118,10 @@ class TestThreadGroupFunctions(unittest.TestCase):
runners = shard._CreateRunners(MockRunner, ['0', '1'])
for runner in runners:
self.assertEqual(runner.setups, 1)
+ self.assertEqual(set([r.device for r in runners]),
+ set(['0', '1']))
+ self.assertEqual(set([r.shard_index for r in runners]),
+ set([0, 1]))
def testRun(self):
runners = [MockRunner('0'), MockRunner('1')]
« no previous file with comments | « build/android/pylib/base/shard.py ('k') | build/android/pylib/browsertests/dispatch.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698