| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Provide common functionality to simulate a google-test executable. | 5 """Provide common functionality to simulate a google-test executable. |
| 6 | 6 |
| 7 http://code.google.com/p/googletest/ | 7 http://code.google.com/p/googletest/ |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 |
| 11 def get_test_output_inner(test_name, failed): |
| 12 fixture, case = test_name.split('.', 1) |
| 13 return ( |
| 14 '[ RUN ] %(fixture)s.%(case)s\n' |
| 15 '%(result)s %(fixture)s.%(case)s (100 ms)\n') % { |
| 16 'fixture': fixture, |
| 17 'case': case, |
| 18 'result': '[ FAILED ]' if failed else '[ OK ]', |
| 19 } |
| 20 |
| 10 def get_test_output(test_name, failed): | 21 def get_test_output(test_name, failed): |
| 11 fixture, case = test_name.split('.', 1) | 22 fixture, _ = test_name.split('.', 1) |
| 12 return ( | 23 return ( |
| 13 '[==========] Running 1 test from 1 test case.\n' | 24 '[==========] Running 1 test from 1 test case.\n' |
| 14 '[----------] Global test environment set-up.\n' | 25 '[----------] Global test environment set-up.\n' |
| 26 '%(content)s' |
| 15 '[----------] 1 test from %(fixture)s\n' | 27 '[----------] 1 test from %(fixture)s\n' |
| 16 '[ RUN ] %(fixture)s.%(case)s\n' | |
| 17 '%(result)s %(fixture)s.%(case)s (100 ms)\n' | |
| 18 '[----------] 1 test from %(fixture)s (100 ms total)\n' | 28 '[----------] 1 test from %(fixture)s (100 ms total)\n' |
| 19 '\n') % { | 29 '\n') % { |
| 30 'content': get_test_output_inner(test_name, failed), |
| 20 'fixture': fixture, | 31 'fixture': fixture, |
| 21 'case': case, | |
| 22 'result': '[ FAILED ]' if failed else '[ OK ]', | |
| 23 } | 32 } |
| 24 | 33 |
| 25 | 34 |
| 26 def get_footer(number, total): | 35 def get_footer(number, total): |
| 27 return ( | 36 return ( |
| 28 '[----------] Global test environment tear-down\n' | 37 '[----------] Global test environment tear-down\n' |
| 29 '[==========] %(number)d test from %(total)d test case ran. (30 ms total)\n' | 38 '[==========] %(number)d test from %(total)d test case ran. (30 ms total)\n' |
| 30 '[ PASSED ] %(number)d test.\n' | 39 '[ PASSED ] %(number)d test.\n' |
| 31 '\n' | 40 '\n' |
| 32 ' YOU HAVE 5 DISABLED TESTS\n' | 41 ' YOU HAVE 5 DISABLED TESTS\n' |
| 33 '\n' | 42 '\n' |
| 34 ' YOU HAVE 2 tests with ignored failures (FAILS prefix)\n') % { | 43 ' YOU HAVE 2 tests with ignored failures (FAILS prefix)\n') % { |
| 35 'number': number, | 44 'number': number, |
| 36 'total': total, | 45 'total': total, |
| 37 } | 46 } |
| OLD | NEW |