OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 import argparse | 6 import argparse |
7 import json | 7 import json |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 import time | 10 import time |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 loader = unittest.loader.TestLoader() | 43 loader = unittest.loader.TestLoader() |
44 print "Running Python unit tests under mojo/public/tools/bindings/pylib ..." | 44 print "Running Python unit tests under mojo/public/tools/bindings/pylib ..." |
45 | 45 |
46 pylib_dir = os.path.join(chromium_src_dir, 'mojo', 'public', | 46 pylib_dir = os.path.join(chromium_src_dir, 'mojo', 'public', |
47 'tools', 'bindings', 'pylib') | 47 'tools', 'bindings', 'pylib') |
48 if args.tests: | 48 if args.tests: |
49 if pylib_dir not in sys.path: | 49 if pylib_dir not in sys.path: |
50 sys.path.append(pylib_dir) | 50 sys.path.append(pylib_dir) |
51 suite = unittest.TestSuite() | 51 suite = unittest.TestSuite() |
52 for test_name in args: | 52 for test_name in args.tests: |
53 suite.addTests(loader.loadTestsFromName(test_name)) | 53 suite.addTests(loader.loadTestsFromName(test_name)) |
54 else: | 54 else: |
55 suite = loader.discover(pylib_dir, pattern='*_unittest.py') | 55 suite = loader.discover(pylib_dir, pattern='*_unittest.py') |
56 | 56 |
57 runner = unittest.runner.TextTestRunner(verbosity=(args.verbose + 1)) | 57 runner = unittest.runner.TextTestRunner(verbosity=(args.verbose + 1)) |
58 result = runner.run(suite) | 58 result = runner.run(suite) |
59 | 59 |
60 full_results = _FullResults(suite, result, args.metadata) | 60 full_results = _FullResults(suite, result, args.metadata) |
61 if args.write_full_results_to: | 61 if args.write_full_results_to: |
62 with open(args.write_full_results_to, 'w') as fp: | 62 with open(args.write_full_results_to, 'w') as fp: |
(...skipping 18 matching lines...) Expand all Loading... |
81 full_results['version'] = 3 | 81 full_results['version'] = 3 |
82 full_results['seconds_since_epoch'] = time.time() | 82 full_results['seconds_since_epoch'] = time.time() |
83 for md in metadata: | 83 for md in metadata: |
84 key, val = md.split('=', 1) | 84 key, val = md.split('=', 1) |
85 full_results[key] = val | 85 full_results[key] = val |
86 | 86 |
87 all_test_names = _AllTestNames(suite) | 87 all_test_names = _AllTestNames(suite) |
88 failed_test_names = _FailedTestNames(result) | 88 failed_test_names = _FailedTestNames(result) |
89 | 89 |
90 full_results['num_failures_by_type'] = { | 90 full_results['num_failures_by_type'] = { |
91 'Failure': len(failed_test_names), | 91 'FAIL': len(failed_test_names), |
92 'Pass': len(all_test_names) - len(failed_test_names), | 92 'PASS': len(all_test_names) - len(failed_test_names), |
93 } | 93 } |
94 | 94 |
95 full_results['tests'] = {} | 95 full_results['tests'] = {} |
96 | 96 |
97 for test_name in all_test_names: | 97 for test_name in all_test_names: |
98 value = { | 98 value = { |
99 'expected': 'PASS', | 99 'expected': 'PASS', |
100 'actual': 'FAIL' if (test_name in failed_test_names) else 'PASS', | 100 'actual': 'FAIL' if (test_name in failed_test_names) else 'PASS', |
101 } | 101 } |
102 _AddPathToTrie(full_results['tests'], test_name, value) | 102 _AddPathToTrie(full_results['tests'], test_name, value) |
(...skipping 21 matching lines...) Expand all Loading... |
124 trie[path] = value | 124 trie[path] = value |
125 return | 125 return |
126 directory, rest = path.split(TEST_SEPARATOR, 1) | 126 directory, rest = path.split(TEST_SEPARATOR, 1) |
127 if directory not in trie: | 127 if directory not in trie: |
128 trie[directory] = {} | 128 trie[directory] = {} |
129 _AddPathToTrie(trie[directory], rest, value) | 129 _AddPathToTrie(trie[directory], rest, value) |
130 | 130 |
131 | 131 |
132 if __name__ == '__main__': | 132 if __name__ == '__main__': |
133 sys.exit(main()) | 133 sys.exit(main()) |
OLD | NEW |