blob: 0c4d1b8143c8157dd79814828ace7761899af376 [file] [log] [blame]
Craig Tillerc2c79212015-02-16 12:00:01 -08001# Copyright 2015, Google Inc.
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met:
7#
8# * Redistributions of source code must retain the above copyright
9# notice, this list of conditions and the following disclaimer.
10# * Redistributions in binary form must reproduce the above
11# copyright notice, this list of conditions and the following disclaimer
12# in the documentation and/or other materials provided with the
13# distribution.
14# * Neither the name of Google Inc. nor the names of its
15# contributors may be used to endorse or promote products derived from
16# this software without specific prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
Nicolas Nobleddef2462015-01-06 18:08:25 -080030"""Run a group of subprocesses and then finish."""
31
Craig Tiller71735182015-01-15 17:07:13 -080032import hashlib
Nicolas Nobleddef2462015-01-06 18:08:25 -080033import multiprocessing
Craig Tiller71735182015-01-15 17:07:13 -080034import os
Craig Tiller5058c692015-04-08 09:42:04 -070035import platform
Craig Tiller336ad502015-02-24 14:46:02 -080036import signal
Nicolas Nobleddef2462015-01-06 18:08:25 -080037import subprocess
38import sys
ctiller3040cb72015-01-07 12:13:17 -080039import tempfile
40import time
Nicolas Nobleddef2462015-01-06 18:08:25 -080041
ctiller3040cb72015-01-07 12:13:17 -080042
ctiller94e5dde2015-01-09 10:41:59 -080043_DEFAULT_MAX_JOBS = 16 * multiprocessing.cpu_count()
Adele Zhoud01cbe32015-11-02 14:20:43 -080044_MAX_RESULT_SIZE = 8192
Nicolas Nobleddef2462015-01-06 18:08:25 -080045
46
Craig Tiller336ad502015-02-24 14:46:02 -080047# setup a signal handler so that signal.pause registers 'something'
48# when a child finishes
49# not using futures and threading to avoid a dependency on subprocess32
Adele Zhoue4c35612015-10-16 15:34:23 -070050if platform.system() == 'Windows':
Craig Tiller5058c692015-04-08 09:42:04 -070051 pass
52else:
53 have_alarm = False
54 def alarm_handler(unused_signum, unused_frame):
55 global have_alarm
56 have_alarm = False
57
58 signal.signal(signal.SIGCHLD, lambda unused_signum, unused_frame: None)
59 signal.signal(signal.SIGALRM, alarm_handler)
Craig Tiller336ad502015-02-24 14:46:02 -080060
61
ctiller3040cb72015-01-07 12:13:17 -080062_SUCCESS = object()
63_FAILURE = object()
64_RUNNING = object()
65_KILLED = object()
66
67
Craig Tiller3b083062015-01-12 13:51:28 -080068_COLORS = {
Nicolas Noble044db742015-01-14 16:57:24 -080069 'red': [ 31, 0 ],
70 'green': [ 32, 0 ],
71 'yellow': [ 33, 0 ],
72 'lightgray': [ 37, 0],
73 'gray': [ 30, 1 ],
Craig Tillerd7e09c32015-09-25 11:33:39 -070074 'purple': [ 35, 0 ],
Craig Tiller3b083062015-01-12 13:51:28 -080075 }
76
77
78_BEGINNING_OF_LINE = '\x1b[0G'
79_CLEAR_LINE = '\x1b[2K'
80
81
82_TAG_COLOR = {
83 'FAILED': 'red',
Craig Tillerd7e09c32015-09-25 11:33:39 -070084 'FLAKE': 'purple',
Craig Tiller3dc1e4f2015-09-25 11:46:56 -070085 'TIMEOUT_FLAKE': 'purple',
Masood Malekghassemie5f70022015-06-29 09:20:26 -070086 'WARNING': 'yellow',
Craig Tillere1d0d1c2015-02-27 08:54:23 -080087 'TIMEOUT': 'red',
Craig Tiller3b083062015-01-12 13:51:28 -080088 'PASSED': 'green',
Nicolas Noble044db742015-01-14 16:57:24 -080089 'START': 'gray',
Craig Tiller3b083062015-01-12 13:51:28 -080090 'WAITING': 'yellow',
Nicolas Noble044db742015-01-14 16:57:24 -080091 'SUCCESS': 'green',
92 'IDLE': 'gray',
Craig Tiller3b083062015-01-12 13:51:28 -080093 }
94
95
Nicolas "Pixel" Noble99768ac2015-05-13 02:34:06 +020096def message(tag, msg, explanatory_text=None, do_newline=False):
97 if message.old_tag == tag and message.old_msg == msg and not explanatory_text:
98 return
99 message.old_tag = tag
100 message.old_msg = msg
Craig Tiller23d2f3f2015-02-24 15:23:32 -0800101 try:
Craig Tiller9f3b2d72015-08-25 11:50:57 -0700102 if platform.system() == 'Windows' or not sys.stdout.isatty():
103 if explanatory_text:
104 print explanatory_text
105 print '%s: %s' % (tag, msg)
106 return
vjpaia29d2d72015-07-08 10:31:15 -0700107 sys.stdout.write('%s%s%s\x1b[%d;%dm%s\x1b[0m: %s%s' % (
108 _BEGINNING_OF_LINE,
109 _CLEAR_LINE,
110 '\n%s' % explanatory_text if explanatory_text is not None else '',
111 _COLORS[_TAG_COLOR[tag]][1],
112 _COLORS[_TAG_COLOR[tag]][0],
113 tag,
114 msg,
115 '\n' if do_newline or explanatory_text is not None else ''))
Craig Tiller23d2f3f2015-02-24 15:23:32 -0800116 sys.stdout.flush()
117 except:
118 pass
Craig Tiller3b083062015-01-12 13:51:28 -0800119
Adele Zhoue4c35612015-10-16 15:34:23 -0700120message.old_tag = ''
121message.old_msg = ''
Craig Tiller3b083062015-01-12 13:51:28 -0800122
Craig Tiller71735182015-01-15 17:07:13 -0800123def which(filename):
124 if '/' in filename:
125 return filename
126 for path in os.environ['PATH'].split(os.pathsep):
127 if os.path.exists(os.path.join(path, filename)):
128 return os.path.join(path, filename)
129 raise Exception('%s not found' % filename)
130
131
Craig Tiller547db2b2015-01-30 14:08:39 -0800132class JobSpec(object):
133 """Specifies what to run for a job."""
134
Jan Tattermusch725835a2015-08-01 21:02:35 -0700135 def __init__(self, cmdline, shortname=None, environ=None, hash_targets=None,
Craig Tiller95cc07b2015-09-28 13:41:30 -0700136 cwd=None, shell=False, timeout_seconds=5*60, flake_retries=0,
Jan Tattermusche2686282015-10-08 16:27:07 -0700137 timeout_retries=0, kill_handler=None):
Craig Tiller547db2b2015-01-30 14:08:39 -0800138 """
139 Arguments:
140 cmdline: a list of arguments to pass as the command line
141 environ: a dictionary of environment variables to set in the child process
142 hash_targets: which files to include in the hash representing the jobs version
143 (or empty, indicating the job should not be hashed)
Jan Tattermusche2686282015-10-08 16:27:07 -0700144 kill_handler: a handler that will be called whenever job.kill() is invoked
Craig Tiller547db2b2015-01-30 14:08:39 -0800145 """
murgatroid99132ce6a2015-03-04 17:29:14 -0800146 if environ is None:
147 environ = {}
148 if hash_targets is None:
149 hash_targets = []
Craig Tiller547db2b2015-01-30 14:08:39 -0800150 self.cmdline = cmdline
151 self.environ = environ
152 self.shortname = cmdline[0] if shortname is None else shortname
153 self.hash_targets = hash_targets or []
Craig Tiller5058c692015-04-08 09:42:04 -0700154 self.cwd = cwd
Jan Tattermusche8243592015-04-17 14:14:01 -0700155 self.shell = shell
Jan Tattermusch725835a2015-08-01 21:02:35 -0700156 self.timeout_seconds = timeout_seconds
Craig Tiller91318bc2015-09-24 08:58:39 -0700157 self.flake_retries = flake_retries
Craig Tillerbfc8a062015-09-28 14:40:21 -0700158 self.timeout_retries = timeout_retries
Jan Tattermusche2686282015-10-08 16:27:07 -0700159 self.kill_handler = kill_handler
Craig Tiller547db2b2015-01-30 14:08:39 -0800160
161 def identity(self):
162 return '%r %r %r' % (self.cmdline, self.environ, self.hash_targets)
163
164 def __hash__(self):
165 return hash(self.identity())
166
167 def __cmp__(self, other):
168 return self.identity() == other.identity()
169
170
Adele Zhoue4c35612015-10-16 15:34:23 -0700171class JobResult(object):
172 def __init__(self):
173 self.state = 'UNKNOWN'
174 self.returncode = -1
175 self.elapsed_time = 0
Adele Zhoud5fffa52015-10-23 15:51:42 -0700176 self.num_failures = 0
Adele Zhoue4c35612015-10-16 15:34:23 -0700177 self.retries = 0
178 self.message = ''
179
180
ctiller3040cb72015-01-07 12:13:17 -0800181class Job(object):
182 """Manages one job."""
183
Adele Zhou2271ab52015-10-28 13:59:14 -0700184 def __init__(self, spec, bin_hash, newline_on_success, travis, add_env):
Craig Tiller547db2b2015-01-30 14:08:39 -0800185 self._spec = spec
Craig Tiller71735182015-01-15 17:07:13 -0800186 self._bin_hash = bin_hash
Nicolas Noble044db742015-01-14 16:57:24 -0800187 self._newline_on_success = newline_on_success
Nicolas "Pixel" Noblea7df3f92015-02-26 22:07:04 +0100188 self._travis = travis
Craig Tiller91318bc2015-09-24 08:58:39 -0700189 self._add_env = add_env.copy()
Craig Tiller91318bc2015-09-24 08:58:39 -0700190 self._retries = 0
Craig Tiller95cc07b2015-09-28 13:41:30 -0700191 self._timeout_retries = 0
Jan Tattermusch91ad0182015-10-01 09:22:03 -0700192 self._suppress_failure_message = False
Craig Tillerb84728d2015-02-26 15:40:39 -0800193 message('START', spec.shortname, do_newline=self._travis)
Adele Zhoue4c35612015-10-16 15:34:23 -0700194 self.result = JobResult()
Craig Tiller91318bc2015-09-24 08:58:39 -0700195 self.start()
196
Adele Zhoue4c35612015-10-16 15:34:23 -0700197 def GetSpec(self):
198 return self._spec
199
Craig Tiller91318bc2015-09-24 08:58:39 -0700200 def start(self):
201 self._tempfile = tempfile.TemporaryFile()
202 env = dict(os.environ)
203 env.update(self._spec.environ)
204 env.update(self._add_env)
205 self._start = time.time()
206 self._process = subprocess.Popen(args=self._spec.cmdline,
207 stderr=subprocess.STDOUT,
208 stdout=self._tempfile,
209 cwd=self._spec.cwd,
210 shell=self._spec.shell,
211 env=env)
212 self._state = _RUNNING
ctiller3040cb72015-01-07 12:13:17 -0800213
Craig Tiller71735182015-01-15 17:07:13 -0800214 def state(self, update_cache):
ctiller3040cb72015-01-07 12:13:17 -0800215 """Poll current state of the job. Prints messages at completion."""
Adele Zhoud01cbe32015-11-02 14:20:43 -0800216 self._tempfile.seek(0)
217 stdout = self._tempfile.read()
218 self.result.message = stdout[-_MAX_RESULT_SIZE:]
ctiller3040cb72015-01-07 12:13:17 -0800219 if self._state == _RUNNING and self._process.poll() is not None:
Craig Tiller9d6139a2015-02-26 15:24:43 -0800220 elapsed = time.time() - self._start
Adele Zhoue4c35612015-10-16 15:34:23 -0700221 self.result.elapsed_time = elapsed
ctiller3040cb72015-01-07 12:13:17 -0800222 if self._process.returncode != 0:
Craig Tiller91318bc2015-09-24 08:58:39 -0700223 if self._retries < self._spec.flake_retries:
224 message('FLAKE', '%s [ret=%d, pid=%d]' % (
Craig Tillerd0ffe142015-05-19 21:51:13 -0700225 self._spec.shortname, self._process.returncode, self._process.pid),
226 stdout, do_newline=True)
Craig Tiller91318bc2015-09-24 08:58:39 -0700227 self._retries += 1
Adele Zhoud5fffa52015-10-23 15:51:42 -0700228 self.result.num_failures += 1
Adele Zhoue4c35612015-10-16 15:34:23 -0700229 self.result.retries = self._timeout_retries + self._retries
Craig Tiller91318bc2015-09-24 08:58:39 -0700230 self.start()
231 else:
232 self._state = _FAILURE
Jan Tattermusch91ad0182015-10-01 09:22:03 -0700233 if not self._suppress_failure_message:
234 message('FAILED', '%s [ret=%d, pid=%d]' % (
235 self._spec.shortname, self._process.returncode, self._process.pid),
236 stdout, do_newline=True)
Adele Zhoue4c35612015-10-16 15:34:23 -0700237 self.result.state = 'FAILED'
Adele Zhoud5fffa52015-10-23 15:51:42 -0700238 self.result.num_failures += 1
Adele Zhoue4c35612015-10-16 15:34:23 -0700239 self.result.returncode = self._process.returncode
ctiller3040cb72015-01-07 12:13:17 -0800240 else:
241 self._state = _SUCCESS
Craig Tiller95cc07b2015-09-28 13:41:30 -0700242 message('PASSED', '%s [time=%.1fsec; retries=%d;%d]' % (
243 self._spec.shortname, elapsed, self._retries, self._timeout_retries),
244 do_newline=self._newline_on_success or self._travis)
Adele Zhoue4c35612015-10-16 15:34:23 -0700245 self.result.state = 'PASSED'
Craig Tiller547db2b2015-01-30 14:08:39 -0800246 if self._bin_hash:
247 update_cache.finished(self._spec.identity(), self._bin_hash)
Jan Tattermusch725835a2015-08-01 21:02:35 -0700248 elif self._state == _RUNNING and time.time() - self._start > self._spec.timeout_seconds:
Craig Tiller95cc07b2015-09-28 13:41:30 -0700249 if self._timeout_retries < self._spec.timeout_retries:
Craig Tiller3dc1e4f2015-09-25 11:46:56 -0700250 message('TIMEOUT_FLAKE', self._spec.shortname, stdout, do_newline=True)
Craig Tiller95cc07b2015-09-28 13:41:30 -0700251 self._timeout_retries += 1
Adele Zhoud5fffa52015-10-23 15:51:42 -0700252 self.result.num_failures += 1
Adele Zhoue4c35612015-10-16 15:34:23 -0700253 self.result.retries = self._timeout_retries + self._retries
Jan Tattermusch39e3cb32015-10-22 18:21:08 -0700254 if self._spec.kill_handler:
255 self._spec.kill_handler(self)
Craig Tiller3dc1e4f2015-09-25 11:46:56 -0700256 self._process.terminate()
257 self.start()
258 else:
259 message('TIMEOUT', self._spec.shortname, stdout, do_newline=True)
260 self.kill()
Adele Zhoue4c35612015-10-16 15:34:23 -0700261 self.result.state = 'TIMEOUT'
Adele Zhoud5fffa52015-10-23 15:51:42 -0700262 self.result.num_failures += 1
ctiller3040cb72015-01-07 12:13:17 -0800263 return self._state
264
265 def kill(self):
266 if self._state == _RUNNING:
267 self._state = _KILLED
Jan Tattermusche2686282015-10-08 16:27:07 -0700268 if self._spec.kill_handler:
269 self._spec.kill_handler(self)
ctiller3040cb72015-01-07 12:13:17 -0800270 self._process.terminate()
271
Jan Tattermusch91ad0182015-10-01 09:22:03 -0700272 def suppress_failure_message(self):
273 self._suppress_failure_message = True
Adele Zhoud5fffa52015-10-23 15:51:42 -0700274
ctiller3040cb72015-01-07 12:13:17 -0800275
Nicolas Nobleddef2462015-01-06 18:08:25 -0800276class Jobset(object):
277 """Manages one run of jobs."""
278
Craig Tiller533b1a22015-05-29 08:41:29 -0700279 def __init__(self, check_cancelled, maxjobs, newline_on_success, travis,
Adele Zhou2271ab52015-10-28 13:59:14 -0700280 stop_on_failure, add_env, cache):
ctiller3040cb72015-01-07 12:13:17 -0800281 self._running = set()
282 self._check_cancelled = check_cancelled
283 self._cancelled = False
Nicolas Nobleddef2462015-01-06 18:08:25 -0800284 self._failures = 0
Craig Tiller738c3342015-01-12 14:28:33 -0800285 self._completed = 0
ctiller94e5dde2015-01-09 10:41:59 -0800286 self._maxjobs = maxjobs
Nicolas Noble044db742015-01-14 16:57:24 -0800287 self._newline_on_success = newline_on_success
Nicolas "Pixel" Noblea7df3f92015-02-26 22:07:04 +0100288 self._travis = travis
Craig Tiller71735182015-01-15 17:07:13 -0800289 self._cache = cache
Craig Tiller533b1a22015-05-29 08:41:29 -0700290 self._stop_on_failure = stop_on_failure
Craig Tiller74e770d2015-06-11 09:38:09 -0700291 self._hashes = {}
Craig Tillerf53d9c82015-08-04 14:19:43 -0700292 self._add_env = add_env
Adele Zhoue4c35612015-10-16 15:34:23 -0700293 self.resultset = {}
294
295 def get_num_failures(self):
296 return self._failures
Nicolas Nobleddef2462015-01-06 18:08:25 -0800297
Craig Tiller547db2b2015-01-30 14:08:39 -0800298 def start(self, spec):
ctiller3040cb72015-01-07 12:13:17 -0800299 """Start a job. Return True on success, False on failure."""
ctiller94e5dde2015-01-09 10:41:59 -0800300 while len(self._running) >= self._maxjobs:
ctiller3040cb72015-01-07 12:13:17 -0800301 if self.cancelled(): return False
302 self.reap()
303 if self.cancelled(): return False
Craig Tiller547db2b2015-01-30 14:08:39 -0800304 if spec.hash_targets:
Craig Tiller74e770d2015-06-11 09:38:09 -0700305 if spec.identity() in self._hashes:
306 bin_hash = self._hashes[spec.identity()]
307 else:
308 bin_hash = hashlib.sha1()
309 for fn in spec.hash_targets:
310 with open(which(fn)) as f:
311 bin_hash.update(f.read())
312 bin_hash = bin_hash.hexdigest()
313 self._hashes[spec.identity()] = bin_hash
Craig Tiller547db2b2015-01-30 14:08:39 -0800314 should_run = self._cache.should_run(spec.identity(), bin_hash)
315 else:
316 bin_hash = None
317 should_run = True
318 if should_run:
Adele Zhoue4c35612015-10-16 15:34:23 -0700319 job = Job(spec,
320 bin_hash,
321 self._newline_on_success,
322 self._travis,
Adele Zhou2271ab52015-10-28 13:59:14 -0700323 self._add_env)
Adele Zhoue4c35612015-10-16 15:34:23 -0700324 self._running.add(job)
Adele Zhoud5fffa52015-10-23 15:51:42 -0700325 self.resultset[job.GetSpec().shortname] = []
ctiller3040cb72015-01-07 12:13:17 -0800326 return True
Nicolas Nobleddef2462015-01-06 18:08:25 -0800327
ctiller3040cb72015-01-07 12:13:17 -0800328 def reap(self):
329 """Collect the dead jobs."""
330 while self._running:
331 dead = set()
332 for job in self._running:
Craig Tiller71735182015-01-15 17:07:13 -0800333 st = job.state(self._cache)
ctiller3040cb72015-01-07 12:13:17 -0800334 if st == _RUNNING: continue
Craig Tiller533b1a22015-05-29 08:41:29 -0700335 if st == _FAILURE or st == _KILLED:
336 self._failures += 1
337 if self._stop_on_failure:
338 self._cancelled = True
339 for job in self._running:
340 job.kill()
ctiller3040cb72015-01-07 12:13:17 -0800341 dead.add(job)
Craig Tiller74e770d2015-06-11 09:38:09 -0700342 break
ctiller3040cb72015-01-07 12:13:17 -0800343 for job in dead:
Craig Tiller738c3342015-01-12 14:28:33 -0800344 self._completed += 1
Adele Zhoud5fffa52015-10-23 15:51:42 -0700345 self.resultset[job.GetSpec().shortname].append(job.result)
ctiller3040cb72015-01-07 12:13:17 -0800346 self._running.remove(job)
Craig Tiller3b083062015-01-12 13:51:28 -0800347 if dead: return
Nicolas "Pixel" Noblea7df3f92015-02-26 22:07:04 +0100348 if (not self._travis):
349 message('WAITING', '%d jobs running, %d complete, %d failed' % (
350 len(self._running), self._completed, self._failures))
Craig Tiller5058c692015-04-08 09:42:04 -0700351 if platform.system() == 'Windows':
352 time.sleep(0.1)
353 else:
354 global have_alarm
355 if not have_alarm:
356 have_alarm = True
357 signal.alarm(10)
358 signal.pause()
ctiller3040cb72015-01-07 12:13:17 -0800359
360 def cancelled(self):
361 """Poll for cancellation."""
362 if self._cancelled: return True
363 if not self._check_cancelled(): return False
364 for job in self._running:
365 job.kill()
366 self._cancelled = True
367 return True
368
369 def finish(self):
370 while self._running:
371 if self.cancelled(): pass # poll cancellation
372 self.reap()
373 return not self.cancelled() and self._failures == 0
Nicolas Nobleddef2462015-01-06 18:08:25 -0800374
375
ctiller3040cb72015-01-07 12:13:17 -0800376def _never_cancelled():
377 return False
378
379
Craig Tiller71735182015-01-15 17:07:13 -0800380# cache class that caches nothing
381class NoCache(object):
382 def should_run(self, cmdline, bin_hash):
383 return True
384
385 def finished(self, cmdline, bin_hash):
386 pass
387
388
Nicolas Nobleb09078f2015-01-14 18:06:05 -0800389def run(cmdlines,
390 check_cancelled=_never_cancelled,
391 maxjobs=None,
Craig Tiller71735182015-01-15 17:07:13 -0800392 newline_on_success=False,
Nicolas "Pixel" Noblea7df3f92015-02-26 22:07:04 +0100393 travis=False,
David Garcia Quintase90cd372015-05-31 18:15:26 -0700394 infinite_runs=False,
Craig Tiller533b1a22015-05-29 08:41:29 -0700395 stop_on_failure=False,
Nicolas "Pixel" Noble5937b5b2015-06-26 02:04:12 +0200396 cache=None,
Craig Tillerf53d9c82015-08-04 14:19:43 -0700397 add_env={}):
ctiller94e5dde2015-01-09 10:41:59 -0800398 js = Jobset(check_cancelled,
Nicolas Noble044db742015-01-14 16:57:24 -0800399 maxjobs if maxjobs is not None else _DEFAULT_MAX_JOBS,
Craig Tillerf53d9c82015-08-04 14:19:43 -0700400 newline_on_success, travis, stop_on_failure, add_env,
Adele Zhou2271ab52015-10-28 13:59:14 -0700401 cache if cache is not None else NoCache())
Craig Tillerb84728d2015-02-26 15:40:39 -0800402 for cmdline in cmdlines:
ctiller3040cb72015-01-07 12:13:17 -0800403 if not js.start(cmdline):
404 break
Adele Zhoue4c35612015-10-16 15:34:23 -0700405 js.finish()
406 return js.get_num_failures(), js.resultset