Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Simulate a passing google-test executable. | 6 """Simulate a passing google-test executable. |
| 7 | 7 |
| 8 http://code.google.com/p/googletest/ | 8 http://code.google.com/p/googletest/ |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 'Bar2', | 21 'Bar2', |
| 22 'Bar/3', | 22 'Bar/3', |
| 23 ]), | 23 ]), |
| 24 } | 24 } |
| 25 TOTAL = sum(len(v) for v in TESTS.itervalues()) | 25 TOTAL = sum(len(v) for v in TESTS.itervalues()) |
| 26 | 26 |
| 27 | 27 |
| 28 def main(): | 28 def main(): |
| 29 parser = optparse.OptionParser() | 29 parser = optparse.OptionParser() |
| 30 parser.add_option('--gtest_list_tests', action='store_true') | 30 parser.add_option('--gtest_list_tests', action='store_true') |
| 31 parser.add_option('--gtest_print_time', action='store_true') | |
|
csharp
2013/03/11 13:33:22
Maybe worth creating a gtest_fake_base class to gr
M-A Ruel
2013/03/11 17:30:53
I'd prefer not do that until they get >100 lines,
| |
| 31 parser.add_option('--gtest_filter') | 32 parser.add_option('--gtest_filter') |
| 32 options, args = parser.parse_args() | 33 options, args = parser.parse_args() |
| 33 if args: | 34 if args: |
| 34 parser.error('Failed to process args %s' % args) | 35 parser.error('Failed to process args %s' % args) |
| 35 | 36 |
| 36 if options.gtest_list_tests: | 37 if options.gtest_list_tests: |
| 37 for fixture, cases in TESTS.iteritems(): | 38 for fixture, cases in TESTS.iteritems(): |
| 38 print '%s.' % fixture | 39 print '%s.' % fixture |
| 39 for case in cases: | 40 for case in cases: |
| 40 print ' ' + case | 41 print ' ' + case |
| 41 print ' YOU HAVE 2 tests with ignored failures (FAILS prefix)' | 42 print ' YOU HAVE 2 tests with ignored failures (FAILS prefix)' |
| 42 print '' | 43 print '' |
| 43 return 0 | 44 return 0 |
| 44 | 45 |
| 45 if options.gtest_filter: | 46 if options.gtest_filter: |
| 46 # Simulate running one test. | 47 # Simulate running one test. |
| 47 print 'Note: Google Test filter = %s\n' % options.gtest_filter | 48 print 'Note: Google Test filter = %s\n' % options.gtest_filter |
| 48 print gtest_fake_base.get_test_output(options.gtest_filter) | 49 for i in options.gtest_filter.split(':'): |
| 50 print gtest_fake_base.get_test_output(i) | |
| 49 print gtest_fake_base.get_footer(1, 1) | 51 print gtest_fake_base.get_footer(1, 1) |
| 50 return 0 | 52 return 0 |
| 51 | 53 |
| 52 for fixture, cases in TESTS.iteritems(): | 54 for fixture, cases in TESTS.iteritems(): |
| 53 for case in cases: | 55 for case in cases: |
| 54 print gtest_fake_base.get_test_output('%s.%s' % (fixture, case)) | 56 print gtest_fake_base.get_test_output('%s.%s' % (fixture, case)) |
| 55 print gtest_fake_base.get_footer(TOTAL, TOTAL) | 57 print gtest_fake_base.get_footer(TOTAL, TOTAL) |
| 56 return 0 | 58 return 0 |
| 57 | 59 |
| 58 | 60 |
| 59 if __name__ == '__main__': | 61 if __name__ == '__main__': |
| 60 sys.exit(main()) | 62 sys.exit(main()) |
| OLD | NEW |