diff options
author | Alistair Veitch <aveitch@google.com> | 2015-10-22 11:27:33 -0700 |
---|---|---|
committer | Alistair Veitch <aveitch@google.com> | 2015-10-22 11:27:33 -0700 |
commit | 5f42b67e1ec759faef14e65f460fb2aaa9a69bf2 (patch) | |
tree | 73304d259d8761d20f3d9538d11fb9537497748e /tools/run_tests/jobset.py | |
parent | f5f720bd9fd486e5d0d03202bf886d145925e85d (diff) | |
parent | 1bc8fa7bf712cb49f74198270dd6b2537f798434 (diff) |
merge & resolve conflicts
Diffstat (limited to 'tools/run_tests/jobset.py')
-rwxr-xr-x | tools/run_tests/jobset.py | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/tools/run_tests/jobset.py b/tools/run_tests/jobset.py index d44104f24c..a9c96a6c95 100755 --- a/tools/run_tests/jobset.py +++ b/tools/run_tests/jobset.py @@ -48,7 +48,7 @@ _DEFAULT_MAX_JOBS = 16 * multiprocessing.cpu_count() # setup a signal handler so that signal.pause registers 'something' # when a child finishes # not using futures and threading to avoid a dependency on subprocess32 -if platform.system() == "Windows": +if platform.system() == 'Windows': pass else: have_alarm = False @@ -118,8 +118,8 @@ def message(tag, msg, explanatory_text=None, do_newline=False): except: pass -message.old_tag = "" -message.old_msg = "" +message.old_tag = '' +message.old_msg = '' def which(filename): if '/' in filename: @@ -177,6 +177,15 @@ class JobSpec(object): return self.identity() == other.identity() +class JobResult(object): + def __init__(self): + self.state = 'UNKNOWN' + self.returncode = -1 + self.elapsed_time = 0 + self.retries = 0 + self.message = '' + + class Job(object): """Manages one job.""" @@ -192,8 +201,12 @@ class Job(object): self._timeout_retries = 0 self._suppress_failure_message = False message('START', spec.shortname, do_newline=self._travis) + self.result = JobResult() self.start() + def GetSpec(self): + return self._spec + def start(self): self._tempfile = tempfile.TemporaryFile() env = dict(os.environ) @@ -219,6 +232,8 @@ class Job(object): # implemented efficiently. This is an experiment to workaround the issue by making sure # results.xml file is small enough. filtered_stdout = filtered_stdout[-128:] + self.result.message = filtered_stdout + self.result.elapsed_time = elapsed if self._xml_test is not None: self._xml_test.set('time', str(elapsed)) ET.SubElement(self._xml_test, 'system-out').text = filtered_stdout @@ -228,6 +243,7 @@ class Job(object): self._spec.shortname, self._process.returncode, self._process.pid), stdout, do_newline=True) self._retries += 1 + self.result.retries = self._timeout_retries + self._retries self.start() else: self._state = _FAILURE @@ -235,6 +251,8 @@ class Job(object): message('FAILED', '%s [ret=%d, pid=%d]' % ( self._spec.shortname, self._process.returncode, self._process.pid), stdout, do_newline=True) + self.result.state = 'FAILED' + self.result.returncode = self._process.returncode if self._xml_test is not None: ET.SubElement(self._xml_test, 'failure', message='Failure') else: @@ -242,20 +260,24 @@ class Job(object): message('PASSED', '%s [time=%.1fsec; retries=%d;%d]' % ( self._spec.shortname, elapsed, self._retries, self._timeout_retries), do_newline=self._newline_on_success or self._travis) + self.result.state = 'PASSED' if self._bin_hash: update_cache.finished(self._spec.identity(), self._bin_hash) elif self._state == _RUNNING and time.time() - self._start > self._spec.timeout_seconds: self._tempfile.seek(0) stdout = self._tempfile.read() filtered_stdout = _filter_stdout(stdout) + self.result.message = filtered_stdout if self._timeout_retries < self._spec.timeout_retries: message('TIMEOUT_FLAKE', self._spec.shortname, stdout, do_newline=True) self._timeout_retries += 1 + self.result.retries = self._timeout_retries + self._retries self._process.terminate() self.start() else: message('TIMEOUT', self._spec.shortname, stdout, do_newline=True) self.kill() + self.result.state = 'TIMEOUT' if self._xml_test is not None: ET.SubElement(self._xml_test, 'system-out').text = filtered_stdout ET.SubElement(self._xml_test, 'error', message='Timeout') @@ -290,6 +312,10 @@ class Jobset(object): self._hashes = {} self._xml_report = xml_report self._add_env = add_env + self.resultset = {} + + def get_num_failures(self): + return self._failures def start(self, spec): """Start a job. Return True on success, False on failure.""" @@ -312,12 +338,14 @@ class Jobset(object): bin_hash = None should_run = True if should_run: - self._running.add(Job(spec, - bin_hash, - self._newline_on_success, - self._travis, - self._add_env, - self._xml_report)) + job = Job(spec, + bin_hash, + self._newline_on_success, + self._travis, + self._add_env, + self._xml_report) + self._running.add(job) + self.resultset[job.GetSpec().shortname] = None return True def reap(self): @@ -337,6 +365,7 @@ class Jobset(object): break for job in dead: self._completed += 1 + self.resultset[job.GetSpec().shortname] = job.result self._running.remove(job) if dead: return if (not self._travis): @@ -398,4 +427,5 @@ def run(cmdlines, for cmdline in cmdlines: if not js.start(cmdline): break - return js.finish() + js.finish() + return js.get_num_failures(), js.resultset |