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

Unified Diff: build/android/pylib/utils/timeout_retry_unittest.py

Issue 2101243005: Add a snapshot of flutter/engine/src/build to our sdk (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add README.dart Created 4 years, 6 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/utils/timeout_retry.py ('k') | build/android/pylib/utils/watchdog_timer.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/utils/timeout_retry_unittest.py
diff --git a/build/android/pylib/utils/timeout_retry_unittest.py b/build/android/pylib/utils/timeout_retry_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..dc36c42ba5cea70edd93c84c078573af3291b6c5
--- /dev/null
+++ b/build/android/pylib/utils/timeout_retry_unittest.py
@@ -0,0 +1,52 @@
+# Copyright 2013 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.
+
+"""Unittests for timeout_and_retry.py."""
+
+import unittest
+
+from pylib.utils import reraiser_thread
+from pylib.utils import timeout_retry
+
+
+class TestException(Exception):
+ pass
+
+
+def _NeverEnding(tries):
+ tries[0] += 1
+ while True:
+ pass
+
+
+def _CountTries(tries):
+ tries[0] += 1
+ raise TestException
+
+
+class TestRun(unittest.TestCase):
+ """Tests for timeout_retry.Run."""
+
+ def testRun(self):
+ self.assertTrue(timeout_retry.Run(
+ lambda x: x, 30, 3, [True], {}))
+
+ def testTimeout(self):
+ tries = [0]
+ self.assertRaises(reraiser_thread.TimeoutError,
+ timeout_retry.Run, lambda: _NeverEnding(tries), 0, 3)
+ self.assertEqual(tries[0], 4)
+
+ def testRetries(self):
+ tries = [0]
+ self.assertRaises(TestException,
+ timeout_retry.Run, lambda: _CountTries(tries), 30, 3)
+ self.assertEqual(tries[0], 4)
+
+ def testReturnValue(self):
+ self.assertTrue(timeout_retry.Run(lambda: True, 30, 3))
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « build/android/pylib/utils/timeout_retry.py ('k') | build/android/pylib/utils/watchdog_timer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698