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 """A "smart" test runner for gtest unit tests (that caches successes).""" | 6 """A "smart" test runner for gtest unit tests (that caches successes).""" |
7 | 7 |
8 import logging | 8 import logging |
9 import os | 9 import os |
| 10 import platform |
10 import subprocess | 11 import subprocess |
11 import sys | 12 import sys |
12 | 13 |
13 _logging = logging.getLogger() | 14 _logging = logging.getLogger() |
14 | 15 |
15 from mopy.transitive_hash import transitive_hash | 16 from mopy.transitive_hash import transitive_hash |
16 | 17 |
17 def main(argv): | 18 def main(argv): |
18 logging.basicConfig() | 19 logging.basicConfig() |
19 # Uncomment to debug: | 20 # Uncomment to debug: |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 successes_cache_file = open(successes_cache_filename, 'ab') \ | 65 successes_cache_file = open(successes_cache_filename, 'ab') \ |
65 if successes_cache_filename else None | 66 if successes_cache_filename else None |
66 for gtest in gtest_list: | 67 for gtest in gtest_list: |
67 if gtest[0] == '*': | 68 if gtest[0] == '*': |
68 gtest = gtest[1:] | 69 gtest = gtest[1:] |
69 _logging.debug("%s is marked as non-cacheable" % gtest) | 70 _logging.debug("%s is marked as non-cacheable" % gtest) |
70 cacheable = False | 71 cacheable = False |
71 else: | 72 else: |
72 cacheable = True | 73 cacheable = True |
73 | 74 |
| 75 if platform.system() == 'Windows': |
| 76 gtest += ".exe" |
| 77 |
74 if successes_cache_file and cacheable: | 78 if successes_cache_file and cacheable: |
75 _logging.debug("Getting transitive hash for %s ... " % gtest) | 79 _logging.debug("Getting transitive hash for %s ... " % gtest) |
76 try: | 80 try: |
77 gtest_hash = transitive_hash(gtest) | 81 gtest_hash = transitive_hash(gtest) |
78 except subprocess.CalledProcessError: | 82 except subprocess.CalledProcessError: |
79 print "Failed to get transitive hash for %s" % gtest | 83 print "Failed to get transitive hash for %s" % gtest |
80 return 1 | 84 return 1 |
81 _logging.debug(" Transitive hash: %s" % gtest_hash) | 85 _logging.debug(" Transitive hash: %s" % gtest_hash) |
82 | 86 |
83 if gtest_hash in successes: | 87 if gtest_hash in successes: |
(...skipping 20 matching lines...) Expand all Loading... |
104 print " Failed to start test" | 108 print " Failed to start test" |
105 return 1 | 109 return 1 |
106 print "All tests succeeded" | 110 print "All tests succeeded" |
107 if successes_cache_file: | 111 if successes_cache_file: |
108 successes_cache_file.close() | 112 successes_cache_file.close() |
109 | 113 |
110 return 0 | 114 return 0 |
111 | 115 |
112 if __name__ == '__main__': | 116 if __name__ == '__main__': |
113 sys.exit(main(sys.argv)) | 117 sys.exit(main(sys.argv)) |
OLD | NEW |