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

Unified Diff: tools/isolate/run_test_cases_test.py

Issue 10533085: Add a unit test for run_test_cases.py. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments Created 8 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 | « tools/isolate/run_test_cases.py ('k') | tools/isolate/worker_pool.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/isolate/run_test_cases_test.py
diff --git a/tools/isolate/run_test_cases_test.py b/tools/isolate/run_test_cases_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..ac4b0f91c5f8f04545623ad1b6b9abf4fa4aee56
--- /dev/null
+++ b/tools/isolate/run_test_cases_test.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 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.
+
+import logging
+import os
+import re
+import subprocess
+import sys
+import unittest
+
+ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
+
+sys.path.append(os.path.join(ROOT_DIR, 'data', 'gtest_fake'))
+import gtest_fake
+
+
+class TraceTestCases(unittest.TestCase):
+ def test_simple(self):
+ target = os.path.join(ROOT_DIR, 'data', 'gtest_fake', 'gtest_fake.py')
+ cmd = [
+ sys.executable,
+ os.path.join(ROOT_DIR, 'run_test_cases.py'),
+ '--no-dump',
+ target,
+ ]
+ proc = subprocess.Popen(
+ cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ # pylint is confused.
+ out, err = proc.communicate() or ('', '')
+ self.assertEquals(0, proc.returncode)
+ expected = (
+ 'Note: Google Test filter = Baz.Fail\n'
+ '\n'
+ '%(test_output)s\n'
+ '%(test_footer)s\n'
+ '\n'
+ 'Success: 3 75.00%%\n'
+ 'Flaky: 0 0.00%%\n'
+ 'Fail: 1 25.00%%\n') % {
+ 'test_output': gtest_fake.get_test_output('Baz.Fail'),
+ 'test_footer': gtest_fake.get_footer(1),
+ }
+
+ self.assertTrue(
+ out.startswith(expected),
+ '\n'.join(['XXX', expected, 'XXX', out[:len(expected)], 'XXX']))
+ remaining_actual = out[len(expected):]
+ regexp = (
+ r'\d+\.\ds Done running 4 tests with 6 executions. \d+\.\d test/s'
+ + '\n')
+ self.assertTrue(re.match(regexp, remaining_actual), remaining_actual)
+ # Progress junk went to stderr.
+ self.assertTrue(err.startswith('\r'), err)
+
+
+if __name__ == '__main__':
+ VERBOSE = '-v' in sys.argv
+ logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR)
+ unittest.main()
« no previous file with comments | « tools/isolate/run_test_cases.py ('k') | tools/isolate/worker_pool.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698