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

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: 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
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..627af588635dca7617371d191cf366e4b23beb10
--- /dev/null
+++ b/tools/isolate/run_test_cases_test.py
@@ -0,0 +1,55 @@
+#!/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')
cmp 2012/06/12 16:32:10 nit: remove extra space after =
M-A Ruel 2012/06/12 17:33:48 I coded that up quickly and it shown. fixed
+ 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 ('', '')
+ expected = (
cmp 2012/06/12 16:32:10 before line 32, can you assert that proc.returncod
M-A Ruel 2012/06/12 17:33:48 Good idea, fixed.
+ 'Note: Google Test filter = Baz.Fail\n\n' +
+ gtest_fake.get_test_output('Baz.Fail') + '\n' +
+ gtest_fake.get_footer(1) + '\n' +
+ '\n'
cmp 2012/06/12 16:32:10 why do you switch from using + above to no + on li
M-A Ruel 2012/06/12 17:33:48 I was abusing string concatenation in python. I ag
+ 'Success: 3 75.00%\n'
+ 'Flaky: 0 0.00%\n'
+ 'Fail: 1 25.00%\n')
+ 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()

Powered by Google App Engine
This is Rietveld 408576698