Commit cfb5a7ee authored by ricow@chromium.org's avatar ricow@chromium.org

Reapply 7581, Fix tools/test.py to allow CTRL+C to work correctly again.

Buildbot now has python 2.6

Also, remove some semicolons.
Review URL: http://codereview.chromium.org/6871007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7626 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent edd2e6bb
...@@ -107,7 +107,7 @@ class MjsunitTestCase(test.TestCase): ...@@ -107,7 +107,7 @@ class MjsunitTestCase(test.TestCase):
return self_script return self_script
def AfterRun(self, result): def AfterRun(self, result):
if self.self_script and (not result.HasPreciousOutput()): if self.self_script and (not result or (not result.HasPreciousOutput())):
test.CheckedUnlink(self.self_script) test.CheckedUnlink(self.self_script)
class MjsunitTestConfiguration(test.TestConfiguration): class MjsunitTestConfiguration(test.TestConfiguration):
......
...@@ -57,7 +57,7 @@ class SputnikTestCase(test.TestCase): ...@@ -57,7 +57,7 @@ class SputnikTestCase(test.TestCase):
def AfterRun(self, result): def AfterRun(self, result):
# Dispose the temporary file if everything looks okay. # Dispose the temporary file if everything looks okay.
if not result.HasPreciousOutput(): self.tmpfile.Dispose() if result is None or not result.HasPreciousOutput(): self.tmpfile.Dispose()
self.tmpfile = None self.tmpfile = None
def GetCommand(self): def GetCommand(self):
......
...@@ -117,6 +117,8 @@ class ProgressIndicator(object): ...@@ -117,6 +117,8 @@ class ProgressIndicator(object):
start = time.time() start = time.time()
output = case.Run() output = case.Run()
case.duration = (time.time() - start) case.duration = (time.time() - start)
except BreakNowException:
self.terminate = True
except IOError, e: except IOError, e:
assert self.terminate assert self.terminate
return return
...@@ -318,6 +320,12 @@ PROGRESS_INDICATORS = { ...@@ -318,6 +320,12 @@ PROGRESS_INDICATORS = {
# --- F r a m e w o r k --- # --- F r a m e w o r k ---
# ------------------------- # -------------------------
class BreakNowException(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class CommandOutput(object): class CommandOutput(object):
...@@ -379,9 +387,12 @@ class TestCase(object): ...@@ -379,9 +387,12 @@ class TestCase(object):
def Run(self): def Run(self):
self.BeforeRun() self.BeforeRun()
result = "exception" result = None
try: try:
result = self.RunCommand(self.GetCommand()) result = self.RunCommand(self.GetCommand())
except:
self.terminate = True
raise BreakNowException("Used pressed CTRL+C or IO went wrong")
finally: finally:
self.AfterRun(result) self.AfterRun(result)
return result return result
...@@ -423,7 +434,7 @@ class TestOutput(object): ...@@ -423,7 +434,7 @@ class TestOutput(object):
self.output.exit_code != -signal.SIGABRT self.output.exit_code != -signal.SIGABRT
def HasTimedOut(self): def HasTimedOut(self):
return self.output.timed_out; return self.output.timed_out
def HasFailed(self): def HasFailed(self):
execution_failed = self.test.DidFail(self.output) execution_failed = self.test.DidFail(self.output)
...@@ -702,7 +713,12 @@ class Context(object): ...@@ -702,7 +713,12 @@ class Context(object):
def RunTestCases(cases_to_run, progress, tasks): def RunTestCases(cases_to_run, progress, tasks):
progress = PROGRESS_INDICATORS[progress](cases_to_run) progress = PROGRESS_INDICATORS[progress](cases_to_run)
return progress.Run(tasks) result = 0
try:
result = progress.Run(tasks)
except Exception, e:
print "\n", e
return result
def BuildRequirements(context, requirements, mode, scons_flags): def BuildRequirements(context, requirements, mode, scons_flags):
...@@ -1339,11 +1355,11 @@ def ShardTests(tests, options): ...@@ -1339,11 +1355,11 @@ def ShardTests(tests, options):
print "shard-run not a valid number, should be in [1:shard-count]" print "shard-run not a valid number, should be in [1:shard-count]"
print "defaulting back to running all tests" print "defaulting back to running all tests"
return tests return tests
count = 0; count = 0
shard = [] shard = []
for test in tests: for test in tests:
if count % options.shard_count == options.shard_run - 1: if count % options.shard_count == options.shard_run - 1:
shard.append(test); shard.append(test)
count += 1 count += 1
return shard return shard
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment