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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import logging
7 import os
8 import re
9 import subprocess
10 import sys
11 import unittest
12
13 ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
14
15 sys.path.append(os.path.join(ROOT_DIR, 'data', 'gtest_fake'))
16 import gtest_fake
17
18
19 class TraceTestCases(unittest.TestCase):
20 def test_simple(self):
21 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
22 cmd = [
23 sys.executable,
24 os.path.join(ROOT_DIR, 'run_test_cases.py'),
25 '--no-dump',
26 target,
27 ]
28 proc = subprocess.Popen(
29 cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
30 # pylint is confused.
31 out, err = proc.communicate() or ('', '')
32 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.
33 'Note: Google Test filter = Baz.Fail\n\n' +
34 gtest_fake.get_test_output('Baz.Fail') + '\n' +
35 gtest_fake.get_footer(1) + '\n' +
36 '\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
37 'Success: 3 75.00%\n'
38 'Flaky: 0 0.00%\n'
39 'Fail: 1 25.00%\n')
40 self.assertTrue(
41 out.startswith(expected),
42 '\n'.join(['XXX', expected, 'XXX', out[:len(expected)], 'XXX']))
43 remaining_actual = out[len(expected):]
44 regexp = (
45 r'\d+\.\ds Done running 4 tests with 6 executions. \d+\.\d test/s'
46 + '\n')
47 self.assertTrue(re.match(regexp, remaining_actual), remaining_actual)
48 # Progress junk went to stderr.
49 self.assertTrue(err.startswith('\r'), err)
50
51
52 if __name__ == '__main__':
53 VERBOSE = '-v' in sys.argv
54 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR)
55 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698