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

Side by Side Diff: tools/testrunner/local/progress.py

Issue 11028027: Revert trunk to bleeding_edge at r12484 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 8 years, 2 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 | « tools/testrunner/local/old_statusfile.py ('k') | tools/testrunner/local/statusfile.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2012 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are
4 # met:
5 #
6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above
9 # copyright notice, this list of conditions and the following
10 # disclaimer in the documentation and/or other materials provided
11 # with the distribution.
12 # * Neither the name of Google Inc. nor the names of its
13 # contributors may be used to endorse or promote products derived
14 # from this software without specific prior written permission.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
29 import sys
30 import time
31
32 def EscapeCommand(command):
33 parts = []
34 for part in command:
35 if ' ' in part:
36 # Escape spaces. We may need to escape more characters for this
37 # to work properly.
38 parts.append('"%s"' % part)
39 else:
40 parts.append(part)
41 return " ".join(parts)
42
43
44 class ProgressIndicator(object):
45
46 def __init__(self):
47 self.runner = None
48
49 def Starting(self):
50 pass
51
52 def Done(self):
53 pass
54
55 def AboutToRun(self, test):
56 pass
57
58 def HasRun(self, test):
59 pass
60
61 def PrintFailureHeader(self, test):
62 if test.suite.IsNegativeTest(test):
63 negative_marker = '[negative] '
64 else:
65 negative_marker = ''
66 print "=== %(label)s %(negative)s===" % {
67 'label': test.GetLabel(),
68 'negative': negative_marker
69 }
70
71
72 class SimpleProgressIndicator(ProgressIndicator):
73 """Abstract base class for {Verbose,Dots}ProgressIndicator"""
74
75 def Starting(self):
76 print 'Running %i tests' % self.runner.total
77
78 def Done(self):
79 print
80 for failed in self.runner.failed:
81 self.PrintFailureHeader(failed)
82 if failed.output.stderr:
83 print "--- stderr ---"
84 print failed.output.stderr.strip()
85 if failed.output.stdout:
86 print "--- stdout ---"
87 print failed.output.stdout.strip()
88 print "Command: %s" % EscapeCommand(self.runner.GetCommand(failed))
89 if failed.output.HasCrashed():
90 print "--- CRASHED ---"
91 if failed.output.HasTimedOut():
92 print "--- TIMEOUT ---"
93 if len(self.runner.failed) == 0:
94 print "==="
95 print "=== All tests succeeded"
96 print "==="
97 else:
98 print
99 print "==="
100 print "=== %i tests failed" % len(self.runner.failed)
101 if self.runner.crashed > 0:
102 print "=== %i tests CRASHED" % self.runner.crashed
103 print "==="
104
105
106 class VerboseProgressIndicator(SimpleProgressIndicator):
107
108 def AboutToRun(self, test):
109 print 'Starting %s...' % test.GetLabel()
110 sys.stdout.flush()
111
112 def HasRun(self, test):
113 if test.suite.HasUnexpectedOutput(test):
114 if test.output.HasCrashed():
115 outcome = 'CRASH'
116 else:
117 outcome = 'FAIL'
118 else:
119 outcome = 'pass'
120 print 'Done running %s: %s' % (test.GetLabel(), outcome)
121
122
123 class DotsProgressIndicator(SimpleProgressIndicator):
124
125 def HasRun(self, test):
126 total = self.runner.succeeded + len(self.runner.failed)
127 if (total > 1) and (total % 50 == 1):
128 sys.stdout.write('\n')
129 if test.suite.HasUnexpectedOutput(test):
130 if test.output.HasCrashed():
131 sys.stdout.write('C')
132 sys.stdout.flush()
133 elif test.output.HasTimedOut():
134 sys.stdout.write('T')
135 sys.stdout.flush()
136 else:
137 sys.stdout.write('F')
138 sys.stdout.flush()
139 else:
140 sys.stdout.write('.')
141 sys.stdout.flush()
142
143
144 class CompactProgressIndicator(ProgressIndicator):
145 """Abstract base class for {Color,Monochrome}ProgressIndicator"""
146
147 def __init__(self, templates):
148 super(CompactProgressIndicator, self).__init__()
149 self.templates = templates
150 self.last_status_length = 0
151 self.start_time = time.time()
152
153 def Done(self):
154 self.PrintProgress('Done')
155
156 def AboutToRun(self, test):
157 self.PrintProgress(test.GetLabel())
158
159 def HasRun(self, test):
160 if test.suite.HasUnexpectedOutput(test):
161 self.ClearLine(self.last_status_length)
162 self.PrintFailureHeader(test)
163 stdout = test.output.stdout.strip()
164 if len(stdout):
165 print self.templates['stdout'] % stdout
166 stderr = test.output.stderr.strip()
167 if len(stderr):
168 print self.templates['stderr'] % stderr
169 print "Command: %s" % EscapeCommand(self.runner.GetCommand(test))
170 if test.output.HasCrashed():
171 print "exit code: %d" % test.output.exit_code
172 print "--- CRASHED ---"
173 if test.output.HasTimedOut():
174 print "--- TIMEOUT ---"
175
176 def Truncate(self, string, length):
177 if length and (len(string) > (length - 3)):
178 return string[:(length - 3)] + "..."
179 else:
180 return string
181
182 def PrintProgress(self, name):
183 self.ClearLine(self.last_status_length)
184 elapsed = time.time() - self.start_time
185 status = self.templates['status_line'] % {
186 'passed': self.runner.succeeded,
187 'remaining': (((self.runner.total - self.runner.remaining) * 100) //
188 self.runner.total),
189 'failed': len(self.runner.failed),
190 'test': name,
191 'mins': int(elapsed) / 60,
192 'secs': int(elapsed) % 60
193 }
194 status = self.Truncate(status, 78)
195 self.last_status_length = len(status)
196 print status,
197 sys.stdout.flush()
198
199
200 class ColorProgressIndicator(CompactProgressIndicator):
201
202 def __init__(self):
203 templates = {
204 'status_line': ("[%(mins)02i:%(secs)02i|"
205 "\033[34m%%%(remaining) 4d\033[0m|"
206 "\033[32m+%(passed) 4d\033[0m|"
207 "\033[31m-%(failed) 4d\033[0m]: %(test)s"),
208 'stdout': "\033[1m%s\033[0m",
209 'stderr': "\033[31m%s\033[0m",
210 }
211 super(ColorProgressIndicator, self).__init__(templates)
212
213 def ClearLine(self, last_line_length):
214 print "\033[1K\r",
215
216
217 class MonochromeProgressIndicator(CompactProgressIndicator):
218
219 def __init__(self):
220 templates = {
221 'status_line': ("[%(mins)02i:%(secs)02i|%%%(remaining) 4d|"
222 "+%(passed) 4d|-%(failed) 4d]: %(test)s"),
223 'stdout': '%s',
224 'stderr': '%s',
225 }
226 super(MonochromeProgressIndicator, self).__init__(templates)
227
228 def ClearLine(self, last_line_length):
229 print ("\r" + (" " * last_line_length) + "\r"),
230
231
232 PROGRESS_INDICATORS = {
233 'verbose': VerboseProgressIndicator,
234 'dots': DotsProgressIndicator,
235 'color': ColorProgressIndicator,
236 'mono': MonochromeProgressIndicator
237 }
OLDNEW
« no previous file with comments | « tools/testrunner/local/old_statusfile.py ('k') | tools/testrunner/local/statusfile.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698