| 34 | |
| 35 | |
| 36 | class Output(object): |
| 37 | |
| 38 | def __init__(self, exit_code=0, timed_out=False, stdout=None, stderr=None, |
| 39 | pid=None, start_time=0, end_time=0, stats=None): |
| 40 | self.exit_code = exit_code |
| 41 | self.timed_out = timed_out |
| 42 | self.stdout = stdout |
| 43 | self.stderr = stderr |
| 44 | self.pid = pid |
| 45 | self.start_time = start_time |
| 46 | self.end_time = end_time |
| 47 | self.stats = stats or ProcessStats() |
| 48 | |
| 49 | @property |
| 50 | def duration(self): |
| 51 | return self.end_time - self.start_time |
| 52 | |
| 53 | def without_text(self): |
| 54 | """Returns copy of the output without stdout and stderr.""" |
| 55 | other = copy.copy(self) |
| 56 | other.stdout = None |
| 57 | other.stderr = None |
| 58 | return other |
| 59 | |
| 60 | def HasCrashed(self): |
| 61 | if utils.IsWindows(): |
| 62 | return 0x80000000 & self.exit_code and not (0x3FFFFF00 & self.exit_code) |
| 63 | else: |
| 64 | # Timed out tests will have exit_code -signal.SIGTERM. |
| 65 | if self.timed_out: |
| 66 | return False |
| 67 | return (self.exit_code < 0 and |
| 68 | self.exit_code != -signal.SIGABRT) |
| 69 | |
| 70 | def HasTimedOut(self): |
| 71 | return self.timed_out |
| 72 | |
| 73 | def IsSuccess(self): |
| 74 | return not self.HasCrashed() and not self.HasTimedOut() |
| 75 | |
| 76 | @property |
| 77 | def exit_code_string(self): |
| 78 | return "%d [%02X]" % (self.exit_code, self.exit_code & 0xffffffff) |
| 79 | |
| 80 | |
| 81 | class _NullOutput(Output): |
no outgoing calls
searching dependent graphs…