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

Side by Side Diff: tools/isolate/tests/run_test_from_archive/gtest_fake.py

Issue 11045023: Move src/tools/isolate to src/tools/swarm_client as a DEPS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use r159961 Created 8 years, 2 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 """Simulate a google-test executable.
7
8 http://code.google.com/p/googletest/
9 """
10
11 import optparse
12 import sys
13
14
15 TESTS = {
16 'Foo': ['Bar1', 'Bar2', 'Bar3'],
17 'Baz': ['Fail'],
18 }
19 TOTAL = sum(len(v) for v in TESTS.itervalues())
20
21
22 def get_test_output(test_name):
23 fixture, case = test_name.split('.', 1)
24 return (
25 '[==========] Running 1 test from 1 test case.\n'
26 '[----------] Global test environment set-up.\n'
27 '[----------] 1 test from %(fixture)s\n'
28 '[ RUN ] %(fixture)s.%(case)s\n'
29 '[ OK ] %(fixture)s.%(case)s (0 ms)\n'
30 '[----------] 1 test from %(fixture)s (0 ms total)\n'
31 '\n') % {
32 'fixture': fixture,
33 'case': case,
34 }
35
36
37 def get_footer(number):
38 return (
39 '[----------] Global test environment tear-down\n'
40 '[==========] %(number)d test from %(total)d test case ran. (0 ms total)\n'
41 '[ PASSED ] %(number)d test.\n'
42 '\n'
43 ' YOU HAVE 5 DISABLED TESTS\n'
44 '\n'
45 ' YOU HAVE 2 tests with ignored failures (FAILS prefix)\n') % {
46 'number': number,
47 'total': TOTAL,
48 }
49
50
51 def main():
52 parser = optparse.OptionParser()
53 parser.add_option('--gtest_list_tests', action='store_true')
54 parser.add_option('--gtest_filter')
55 options, args = parser.parse_args()
56 if args:
57 parser.error('Failed to process args %s' % args)
58
59 if options.gtest_list_tests:
60 for fixture, cases in TESTS.iteritems():
61 print '%s.' % fixture
62 for case in cases:
63 print ' ' + case
64 print ' YOU HAVE 2 tests with ignored failures (FAILS prefix)'
65 print ''
66 return 0
67
68 if options.gtest_filter:
69 # Simulate running one test.
70 print 'Note: Google Test filter = %s\n' % options.gtest_filter
71 print get_test_output(options.gtest_filter)
72 print get_footer(1)
73 # Make Baz.Fail fail.
74 return options.gtest_filter == 'Baz.Fail'
75
76 for fixture, cases in TESTS.iteritems():
77 for case in cases:
78 print get_test_output('%s.%s' % (fixture, case))
79 print get_footer(TOTAL)
80 return 6
81
82
83 if __name__ == '__main__':
84 sys.exit(main())
OLDNEW
« no previous file with comments | « tools/isolate/tests/run_test_from_archive/file3.txt ('k') | tools/isolate/tests/run_test_from_archive/gtest_fake.results » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698