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 passing 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 } |
| 20 TOTAL = sum(len(v) for v in TESTS.itervalues()) |
| 21 |
| 22 |
| 23 def main(): |
| 24 parser = optparse.OptionParser() |
| 25 parser.add_option('--gtest_list_tests', action='store_true') |
| 26 parser.add_option('--gtest_filter') |
| 27 options, args = parser.parse_args() |
| 28 if args: |
| 29 parser.error('Failed to process args %s' % args) |
| 30 |
| 31 if options.gtest_list_tests: |
| 32 for fixture, cases in TESTS.iteritems(): |
| 33 print '%s.' % fixture |
| 34 for case in cases: |
| 35 print ' ' + case |
| 36 print ' YOU HAVE 2 tests with ignored failures (FAILS prefix)' |
| 37 print '' |
| 38 return 0 |
| 39 |
| 40 if options.gtest_filter: |
| 41 # Simulate running one test. |
| 42 print 'Note: Google Test filter = %s\n' % options.gtest_filter |
| 43 print gtest_fake_base.get_test_output(options.gtest_filter) |
| 44 print gtest_fake_base.get_footer(1, 1) |
| 45 return 0 |
| 46 |
| 47 for fixture, cases in TESTS.iteritems(): |
| 48 for case in cases: |
| 49 print gtest_fake_base.get_test_output('%s.%s' % (fixture, case)) |
| 50 print gtest_fake_base.get_footer(TOTAL, TOTAL) |
| 51 return 0 |
| 52 |
| 53 |
| 54 if __name__ == '__main__': |
| 55 sys.exit(main()) |
OLD | NEW |