Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: mojo/tools/test_runner.py

Issue 292353003: Mojo: Make mojob.sh not skip some tests (due to cached test results). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add mojo_public_bindings_unittests Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mojo/tools/data/unittests ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 subprocess 10 import subprocess
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 # Run gtests with color if we're on a TTY (and we're not being told explicitly 60 # Run gtests with color if we're on a TTY (and we're not being told explicitly
61 # what to do). 61 # what to do).
62 if sys.stdout.isatty() and 'GTEST_COLOR' not in os.environ: 62 if sys.stdout.isatty() and 'GTEST_COLOR' not in os.environ:
63 _logging.debug("Setting GTEST_COLOR=yes") 63 _logging.debug("Setting GTEST_COLOR=yes")
64 os.environ['GTEST_COLOR'] = 'yes' 64 os.environ['GTEST_COLOR'] = 'yes'
65 65
66 # TODO(vtl): We may not close this file on failure. 66 # TODO(vtl): We may not close this file on failure.
67 successes_cache_file = open(successes_cache_filename, 'ab') \ 67 successes_cache_file = open(successes_cache_filename, 'ab') \
68 if successes_cache_filename else None 68 if successes_cache_filename else None
69 for gtest in gtest_list: 69 for gtest in gtest_list:
70 if successes_cache_file: 70 if gtest[0] == '*':
71 gtest = gtest[1:]
72 _logging.debug("%s is marked as non-cacheable" % gtest)
73 cacheable = False
74 else:
75 cacheable = True
76
77 if successes_cache_file and cacheable:
71 _logging.debug("Getting transitive hash for %s ... " % gtest) 78 _logging.debug("Getting transitive hash for %s ... " % gtest)
72 try: 79 try:
73 gtest_hash = transitive_hash(gtest) 80 gtest_hash = transitive_hash(gtest)
74 except: 81 except:
75 print "Failed to get transitive hash for %s" % gtest 82 print "Failed to get transitive hash for %s" % gtest
76 return 1 83 return 1
77 _logging.debug(" Transitive hash: %s" % gtest_hash) 84 _logging.debug(" Transitive hash: %s" % gtest_hash)
78 85
79 if gtest_hash in successes: 86 if gtest_hash in successes:
80 print "Skipping %s (previously succeeded)" % gtest 87 print "Skipping %s (previously succeeded)" % gtest
81 continue 88 continue
82 89
83 print "Running %s ..." % gtest 90 print "Running %s...." % gtest,
84 try: 91 try:
85 subprocess.check_output(["./" + gtest], stderr=subprocess.STDOUT) 92 subprocess.check_output(["./" + gtest], stderr=subprocess.STDOUT)
86 print " Succeeded" 93 print "Succeeded"
87 # Record success. 94 # Record success.
88 if successes_cache_filename: 95 if successes_cache_filename and cacheable:
89 successes.add(gtest_hash) 96 successes.add(gtest_hash)
90 successes_cache_file.write(gtest_hash + '\n') 97 successes_cache_file.write(gtest_hash + '\n')
91 successes_cache_file.flush() 98 successes_cache_file.flush()
92 except subprocess.CalledProcessError as e: 99 except subprocess.CalledProcessError as e:
93 print " Failed with exit code %d and output:" % e.returncode 100 print "Failed with exit code %d and output:" % e.returncode
94 print 72 * '-' 101 print 72 * '-'
95 print e.output 102 print e.output
96 print 72 * '-' 103 print 72 * '-'
97 return 1 104 return 1
98 except OSError as e: 105 except OSError as e:
99 print " Failed to start test" 106 print " Failed to start test"
100 return 1 107 return 1
101 print "All tests succeeded" 108 print "All tests succeeded"
102 if successes_cache_file: 109 if successes_cache_file:
103 successes_cache_file.close() 110 successes_cache_file.close()
104 111
105 return 0 112 return 0
106 113
107 if __name__ == '__main__': 114 if __name__ == '__main__':
108 sys.exit(main(sys.argv)) 115 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « mojo/tools/data/unittests ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698