Reviewers: Lasse Reichstein,

Description:
Fix tools/test.py to allow CTRL+C to work correctly again.

This also changes the AfterRun functions to allow None as the passed in
parameter.

Please review this at http://codereview.chromium.org/6824040/

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     test/mjsunit/testcfg.py
  M     test/sputnik/testcfg.py
  M     tools/test.py


Index: test/mjsunit/testcfg.py
===================================================================
--- test/mjsunit/testcfg.py     (revision 7551)
+++ test/mjsunit/testcfg.py     (working copy)
@@ -107,7 +107,7 @@
     return self_script

   def AfterRun(self, result):
-    if self.self_script and (not result.HasPreciousOutput()):
+ if self.self_script and (result is None or (not result.HasPreciousOutput())):
       test.CheckedUnlink(self.self_script)

 class MjsunitTestConfiguration(test.TestConfiguration):
Index: test/sputnik/testcfg.py
===================================================================
--- test/sputnik/testcfg.py     (revision 7551)
+++ test/sputnik/testcfg.py     (working copy)
@@ -57,7 +57,7 @@

   def AfterRun(self, result):
     # 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

   def GetCommand(self):
Index: tools/test.py
===================================================================
--- tools/test.py       (revision 7566)
+++ tools/test.py       (working copy)
@@ -117,6 +117,8 @@
         start = time.time()
         output = case.Run()
         case.duration = (time.time() - start)
+      except BreakNowException:
+        self.terminate = True
       except IOError, e:
         assert self.terminate
         return
@@ -318,7 +320,13 @@
 # --- 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):

   def __init__(self, exit_code, timed_out, stdout, stderr):
@@ -379,9 +387,12 @@

   def Run(self):
     self.BeforeRun()
-    result = "exception"
+    result = None;
     try:
       result = self.RunCommand(self.GetCommand())
+    except:
+      self.terminate = True;
+      raise BreakNowException("Used pressed CTRL+C or IO went wrong")
     finally:
       self.AfterRun(result)
     return result
@@ -702,7 +713,12 @@

 def RunTestCases(cases_to_run, progress, tasks):
   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):


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to