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

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

Issue 69143004: Delete swarm_client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/
Patch Set: Created 7 years, 1 month 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 # Copyright 2013 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 'number': number,
48 'total': total,
49 }
50
51
52 def parse_args(all_tests, need_arg):
53 """Creates a generic google-test like python script."""
54 parser = optparse.OptionParser()
55 parser.add_option('--gtest_list_tests', action='store_true')
56 parser.add_option('--gtest_print_time', action='store_true')
57 parser.add_option('--gtest_filter')
58 options, args = parser.parse_args()
59 if need_arg != len(args):
60 parser.error(
61 'Expected %d arguments, got %d; %s' % (
62 need_arg, len(args), ' '.join(args)))
63
64 if options.gtest_list_tests:
65 for fixture, cases in all_tests.iteritems():
66 print '%s.' % fixture
67 for case in cases:
68 print ' ' + case
69 sys.exit(0)
70
71 if options.gtest_filter:
72 print 'Note: Google Test filter = %s\n' % options.gtest_filter
73 test_cases = options.gtest_filter.split(':')
74 else:
75 test_cases = sum((
76 ['%s.%s' % (f, c) for c in all_tests[f]] for f in all_tests), [])
77 return sorted(test_cases), args
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698