| OLD | NEW |
| 1 # Copyright 2012 the V8 project authors. All rights reserved. | 1 # Copyright 2012 the V8 project authors. All rights reserved. |
| 2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
| 3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
| 4 # met: | 4 # met: |
| 5 # | 5 # |
| 6 # * Redistributions of source code must retain the above copyright | 6 # * Redistributions of source code must retain the above copyright |
| 7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
| 8 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
| 9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
| 10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 | 28 |
| 29 import sys | 29 import sys |
| 30 import time | 30 import time |
| 31 | 31 |
| 32 from . import junit_output |
| 33 |
| 32 def EscapeCommand(command): | 34 def EscapeCommand(command): |
| 33 parts = [] | 35 parts = [] |
| 34 for part in command: | 36 for part in command: |
| 35 if ' ' in part: | 37 if ' ' in part: |
| 36 # Escape spaces. We may need to escape more characters for this | 38 # Escape spaces. We may need to escape more characters for this |
| 37 # to work properly. | 39 # to work properly. |
| 38 parts.append('"%s"' % part) | 40 parts.append('"%s"' % part) |
| 39 else: | 41 else: |
| 40 parts.append(part) | 42 parts.append(part) |
| 41 return " ".join(parts) | 43 return " ".join(parts) |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 "+%(passed) 4d|-%(failed) 4d]: %(test)s"), | 225 "+%(passed) 4d|-%(failed) 4d]: %(test)s"), |
| 224 'stdout': '%s', | 226 'stdout': '%s', |
| 225 'stderr': '%s', | 227 'stderr': '%s', |
| 226 } | 228 } |
| 227 super(MonochromeProgressIndicator, self).__init__(templates) | 229 super(MonochromeProgressIndicator, self).__init__(templates) |
| 228 | 230 |
| 229 def ClearLine(self, last_line_length): | 231 def ClearLine(self, last_line_length): |
| 230 print ("\r" + (" " * last_line_length) + "\r"), | 232 print ("\r" + (" " * last_line_length) + "\r"), |
| 231 | 233 |
| 232 | 234 |
| 235 class JUnitTestProgressIndicator(ProgressIndicator): |
| 236 |
| 237 def __init__(self, progress_indicator, junitout, junittestsuite): |
| 238 self.progress_indicator = progress_indicator |
| 239 self.outputter = junit_output.JUnitTestOutput(junittestsuite) |
| 240 if junitout: |
| 241 self.outfile = open(junitout, "w") |
| 242 else: |
| 243 self.outfile = sys.stdout |
| 244 |
| 245 def Starting(self): |
| 246 self.progress_indicator.runner = self.runner |
| 247 self.progress_indicator.Starting() |
| 248 |
| 249 def Done(self): |
| 250 self.progress_indicator.Done() |
| 251 self.outputter.FinishAndWrite(self.outfile) |
| 252 if self.outfile != sys.stdout: |
| 253 self.outfile.close() |
| 254 |
| 255 def AboutToRun(self, test): |
| 256 self.progress_indicator.AboutToRun(test) |
| 257 |
| 258 def HasRun(self, test): |
| 259 self.progress_indicator.HasRun(test) |
| 260 fail_text = "" |
| 261 if test.suite.HasUnexpectedOutput(test): |
| 262 stdout = test.output.stdout.strip() |
| 263 if len(stdout): |
| 264 fail_text += "stdout:\n%s\n" % stdout |
| 265 stderr = test.output.stderr.strip() |
| 266 if len(stderr): |
| 267 fail_text += "stderr:\n%s\n" % stderr |
| 268 fail_text += "Command: %s" % EscapeCommand(self.runner.GetCommand(test)) |
| 269 if test.output.HasCrashed(): |
| 270 fail_text += "exit code: %d\n--- CRASHED ---" % test.output.exit_code |
| 271 if test.output.HasTimedOut(): |
| 272 fail_text += "--- TIMEOUT ---" |
| 273 self.outputter.HasRunTest( |
| 274 [test.GetLabel()] + self.runner.context.mode_flags + test.flags, |
| 275 test.duration, |
| 276 fail_text) |
| 277 |
| 278 |
| 233 PROGRESS_INDICATORS = { | 279 PROGRESS_INDICATORS = { |
| 234 'verbose': VerboseProgressIndicator, | 280 'verbose': VerboseProgressIndicator, |
| 235 'dots': DotsProgressIndicator, | 281 'dots': DotsProgressIndicator, |
| 236 'color': ColorProgressIndicator, | 282 'color': ColorProgressIndicator, |
| 237 'mono': MonochromeProgressIndicator | 283 'mono': MonochromeProgressIndicator |
| 238 } | 284 } |
| OLD | NEW |