OLD | NEW |
| (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 failing google-test executable. | |
7 | |
8 http://code.google.com/p/googletest/ | |
9 """ | |
10 | |
11 import optparse | |
12 import sys | |
13 | |
14 import gtest_fake_base | |
15 | |
16 | |
17 TESTS = { | |
18 'Foo': ['Bar1', 'Bar2', 'Bar3'], | |
19 'Baz': ['Fail'], | |
20 } | |
21 TOTAL = sum(len(v) for v in TESTS.itervalues()) | |
22 | |
23 | |
24 def main(): | |
25 parser = optparse.OptionParser() | |
26 parser.add_option('--gtest_list_tests', action='store_true') | |
27 parser.add_option('--gtest_filter') | |
28 options, args = parser.parse_args() | |
29 if args: | |
30 parser.error('Failed to process args %s' % args) | |
31 | |
32 if options.gtest_list_tests: | |
33 for fixture, cases in TESTS.iteritems(): | |
34 print '%s.' % fixture | |
35 for case in cases: | |
36 print ' ' + case | |
37 print ' YOU HAVE 2 tests with ignored failures (FAILS prefix)' | |
38 print '' | |
39 return 0 | |
40 | |
41 if options.gtest_filter: | |
42 # Simulate running one test. | |
43 print 'Note: Google Test filter = %s\n' % options.gtest_filter | |
44 print gtest_fake_base.get_test_output(options.gtest_filter) | |
45 print gtest_fake_base.get_footer(1, 1) | |
46 # Make Baz.Fail fail. | |
47 return options.gtest_filter == 'Baz.Fail' | |
48 | |
49 for fixture, cases in TESTS.iteritems(): | |
50 for case in cases: | |
51 print gtest_fake_base.get_test_output('%s.%s' % (fixture, case)) | |
52 print gtest_fake_base.get_footer(TOTAL, TOTAL) | |
53 return 1 | |
54 | |
55 | |
56 if __name__ == '__main__': | |
57 sys.exit(main()) | |
OLD | NEW |