scriptname = os.path.abspath(sys.argv[0])
_Cmd("svn cat %s > %s" % (path, scriptname))
+ # The testcfg.py files currently need to be able to import the old test.py
+ # script, so we temporarily need to make that available.
+ # TODO(jkummerow): Remove this when removing test.py.
+ for filename in ("test.py", "utils.py"):
+ url = ("http://v8.googlecode.com/svn/branches/bleeding_edge/"
+ "tools/%s" % filename)
+ filepath = os.path.join(os.path.dirname(scriptname), filename)
+ _Cmd("svn cat %s > %s" % (url, filepath))
+
# Check out or update V8.
v8_dir = os.path.join(ROOT, "v8")
if os.path.exists(v8_dir):
from . import utils
+BREAK_NOW = -1
+EXCEPTION = -2
+
+
class Job(object):
def __init__(self, command, dep_command, test_id, timeout, verbose):
self.command = command
return (job.id, dep_output, time.time() - start_time)
output = commands.Execute(job.command, job.verbose, job.timeout)
return (job.id, output, time.time() - start_time)
+ except KeyboardInterrupt:
+ return (-1, BREAK_NOW, 0)
except Exception, e:
print(">>> EXCEPTION: %s" % e)
- return (-1, -1, 0)
+ return (-1, EXCEPTION, 0)
class Runner(object):
pool = multiprocessing.Pool(processes=jobs)
test_map = {}
queue = []
+ queued_exception = None
for test in self.tests:
assert test.id >= 0
test_map[test.id] = test
- command = self.GetCommand(test)
+ try:
+ command = self.GetCommand(test)
+ except Exception, e:
+ # If this failed, save the exception and re-raise it later (after
+ # all other tests have had a chance to run).
+ queued_exception = e
+ continue
timeout = self.context.timeout
if ("--stress-opt" in test.flags or
"--stress-opt" in self.context.mode_flags or
for result in it:
test_id = result[0]
if test_id < 0:
+ if result[1] == BREAK_NOW:
+ self.terminate = True
+ else:
+ continue
+ if self.terminate:
+ pool.terminate()
+ pool.join()
raise BreakNowException("User pressed Ctrl+C or IO went wrong")
test = test_map[test_id]
self.indicator.AboutToRun(test)
self.succeeded += 1
self.remaining -= 1
self.indicator.HasRun(test)
- except:
+ except KeyboardInterrupt:
+ pool.terminate()
+ pool.join()
+ except Exception, e:
+ print("Exception: %s" % e)
pool.terminate()
pool.join()
raise
+ if queued_exception:
+ raise queued_exception
return
self.sender_lock.acquire()
while keep_running:
time.sleep(0.1)
- t1 = time.time()
# This should be "atomic enough" without locking :-)
# (We don't care which list any new elements get appended to, as long
# as we don't lose any and the last one comes last.)
result = []
for t in tests:
result.append(t.PackResult())
- compression.Send(result, self.sock)
+ try:
+ compression.Send(result, self.sock)
+ except:
+ self.runner.terminate = True
for t in tests:
self.server.CompareOwnPerf(t, self.context.arch, self.context.mode)
tests = []
e.filename)
else:
message = "%s" % e
- compression.Send([-1, message], sock)
+ compression.Send([[-1, message]], sock)
progress_indicator.HasRun(None) # Sentinel to signal the end.
progress_indicator.sender_lock.acquire() # Released when sending is done.
progress_indicator.sender_lock.release()
test_id = data[0]
if test_id < 0:
# The peer is reporting an error.
- print("Peer %s reports error: %s" % (peer.address, data[1]))
- rec.Advance()
+ with self.lock:
+ print("\nPeer %s reports error: %s" % (peer.address, data[1]))
continue
test = test_map.pop(test_id)
test.MergeResult(data)
self.indicator.HasRun(test)
rec.Advance()
peer.runtime = time.time() - start_time
- except Exception:
+ except KeyboardInterrupt:
+ sock.close()
+ raise
+ except Exception, e:
+ print("Got exception: %s" % e)
pass # Fall back to local execution.
else:
compression.Send([constants.UNRESPONSIVE_PEER, peer.address],
sock.close()
if len(test_map) > 0:
# Some tests have not received any results. Run them locally.
- print("No results for %d tests, running them locally." % len(test_map))
+ print("\nNo results for %d tests, running them locally." % len(test_map))
self._EnqueueLocally(test_map)
def _EnqueueLocally(self, test_map):
def _SendResponse(self, error_message=None):
try:
if error_message:
- compression.Send([-1, error_message], self.request)
+ compression.Send([[-1, error_message]], self.request)
compression.Send(constants.END_OF_STREAM, self.request)
return
except Exception, e: