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 import logging |
| 7 import os |
| 8 import re |
| 9 import subprocess |
| 10 import sys |
| 11 import unittest |
| 12 |
| 13 ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 14 |
| 15 sys.path.append(os.path.join(ROOT_DIR, 'data', 'gtest_fake')) |
| 16 import gtest_fake |
| 17 |
| 18 |
| 19 class TraceTestCases(unittest.TestCase): |
| 20 def test_simple(self): |
| 21 target = os.path.join(ROOT_DIR, 'data', 'gtest_fake', 'gtest_fake.py') |
| 22 cmd = [ |
| 23 sys.executable, |
| 24 os.path.join(ROOT_DIR, 'run_test_cases.py'), |
| 25 '--no-dump', |
| 26 target, |
| 27 ] |
| 28 proc = subprocess.Popen( |
| 29 cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 30 # pylint is confused. |
| 31 out, err = proc.communicate() or ('', '') |
| 32 self.assertEquals(0, proc.returncode) |
| 33 expected = ( |
| 34 'Note: Google Test filter = Baz.Fail\n' |
| 35 '\n' |
| 36 '%(test_output)s\n' |
| 37 '%(test_footer)s\n' |
| 38 '\n' |
| 39 'Success: 3 75.00%%\n' |
| 40 'Flaky: 0 0.00%%\n' |
| 41 'Fail: 1 25.00%%\n') % { |
| 42 'test_output': gtest_fake.get_test_output('Baz.Fail'), |
| 43 'test_footer': gtest_fake.get_footer(1), |
| 44 } |
| 45 |
| 46 self.assertTrue( |
| 47 out.startswith(expected), |
| 48 '\n'.join(['XXX', expected, 'XXX', out[:len(expected)], 'XXX'])) |
| 49 remaining_actual = out[len(expected):] |
| 50 regexp = ( |
| 51 r'\d+\.\ds Done running 4 tests with 6 executions. \d+\.\d test/s' |
| 52 + '\n') |
| 53 self.assertTrue(re.match(regexp, remaining_actual), remaining_actual) |
| 54 # Progress junk went to stderr. |
| 55 self.assertTrue(err.startswith('\r'), err) |
| 56 |
| 57 |
| 58 if __name__ == '__main__': |
| 59 VERBOSE = '-v' in sys.argv |
| 60 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR) |
| 61 unittest.main() |
OLD | NEW |