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

Side by Side Diff: tests/gtest_fake/gtest_fake_base.py

Issue 19917006: Move all googletest related scripts into googletest/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/swarm_client
Patch Set: Remove unnecessary pylint warning disable Created 7 years, 5 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
« no previous file with comments | « tests/gtest_fake/expected.xml ('k') | tests/gtest_fake/gtest_fake_confused_fail.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Provide common functionality to simulate a google-test executable.
6
7 http://code.google.com/p/googletest/
8 """
9
10 import optparse
11 import sys
12
13
14 def get_test_output_inner(test_name, failed, duration='100'):
15 fixture, case = test_name.split('.', 1)
16 return (
17 '[ RUN ] %(fixture)s.%(case)s\n'
18 '%(result)s %(fixture)s.%(case)s (%(duration)s ms)\n') % {
19 'case': case,
20 'duration': duration,
21 'fixture': fixture,
22 'result': '[ FAILED ]' if failed else '[ OK ]',
23 }
24
25 def get_test_output(test_name, failed, duration='100'):
26 fixture, _ = test_name.split('.', 1)
27 return (
28 '[==========] Running 1 test from 1 test case.\n'
29 '[----------] Global test environment set-up.\n'
30 '%(content)s'
31 '[----------] 1 test from %(fixture)s\n'
32 '[----------] 1 test from %(fixture)s (%(duration)s ms total)\n'
33 '\n') % {
34 'content': get_test_output_inner(test_name, failed, duration),
35 'duration': duration,
36 'fixture': fixture,
37 }
38
39
40 def get_footer(number, total):
41 return (
42 '[----------] Global test environment tear-down\n'
43 '[==========] %(number)d test from %(total)d test case ran. (30 ms total)\n'
44 '[ PASSED ] %(number)d test.\n'
45 '\n'
46 ' YOU HAVE 5 DISABLED TESTS\n'
47 '\n'
48 ' YOU HAVE 2 tests with ignored failures (FAILS prefix)\n') % {
49 'number': number,
50 'total': total,
51 }
52
53
54 def parse_args(all_tests, need_arg):
55 """Creates a generic google-test like python script."""
56 parser = optparse.OptionParser()
57 parser.add_option('--gtest_list_tests', action='store_true')
58 parser.add_option('--gtest_print_time', action='store_true')
59 parser.add_option('--gtest_filter')
60 options, args = parser.parse_args()
61 if need_arg != len(args):
62 parser.error(
63 'Expected %d arguments, got %d; %s' % (
64 need_arg, len(args), ' '.join(args)))
65
66 if options.gtest_list_tests:
67 for fixture, cases in all_tests.iteritems():
68 print '%s.' % fixture
69 for case in cases:
70 print ' ' + case
71 print ' YOU HAVE 2 tests with ignored failures (FAILS prefix)'
72 print ''
73 sys.exit(0)
74
75 if options.gtest_filter:
76 print 'Note: Google Test filter = %s\n' % options.gtest_filter
77 test_cases = options.gtest_filter.split(':')
78 else:
79 test_cases = sum((
80 ['%s.%s' % (f, c) for c in all_tests[f]] for f in all_tests), [])
81 return sorted(test_cases), args
OLDNEW
« no previous file with comments | « tests/gtest_fake/expected.xml ('k') | tests/gtest_fake/gtest_fake_confused_fail.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698