Bug 688762 - add try/except blocks around all harnesses so we always return an error code. r=bear
authorJoel Maher <jmaher@mozilla.com>
Mon, 26 Sep 2011 07:41:19 -0400
changeset 77574 3995f7c64af8de1a7259c3a89b12d94f825caa35
parent 77573 0c880a09186d4afeddeda29bc191a1691e86804a
child 77575 1a11c6516cda06d73a5638129a203434c13a2435
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersbear
bugs688762
milestone9.0a1
Bug 688762 - add try/except blocks around all harnesses so we always return an error code. r=bear
build/mobile/devicemanagerSUT.py
layout/tools/reftest/remotereftest.py
testing/mochitest/runtestsremote.py
--- a/build/mobile/devicemanagerSUT.py
+++ b/build/mobile/devicemanagerSUT.py
@@ -701,17 +701,21 @@ class DeviceManagerSUT(DeviceManager):
   # external function
   # returns:
   #  success: output of pullfile, string
   #  failure: None
   def getFile(self, remoteFile, localFile = ''):
     if localFile == '':
       localFile = os.path.join(self.tempRoot, "temp.txt")
   
-    retVal = self.pullFile(remoteFile)
+    try:
+      retVal = self.pullFile(remoteFile)
+    except:
+      return None
+      
     if (retVal is None):
       return None
 
     fhandle = open(localFile, 'wb')
     fhandle.write(retVal)
     fhandle.close()
     if not self.validateFile(remoteFile, localFile):
       print 'failed to validate file when downloading %s!' % remoteFile
--- a/layout/tools/reftest/remotereftest.py
+++ b/layout/tools/reftest/remotereftest.py
@@ -435,13 +435,19 @@ def main():
         manifest = "http://" + str(options.remoteWebServer) + ":" + str(options.httpPort) + "/" + manifestPath
 
     procName = options.app.split('/')[-1]
     if (dm.processExist(procName)):
       dm.killProcess(procName)
 
 #an example manifest name to use on the cli
 #    manifest = "http://" + options.remoteWebServer + "/reftests/layout/reftests/reftest-sanity/reftest.list"
-    reftest.runTests(manifest, options)
+    try:
+      reftest.runTests(manifest, options)
+    except:
+      print "TEST-UNEXPECTED-FAIL | | exception while running reftests"
+      reftest.stopWebServer(options)
+      sys.exit(1)
+
     reftest.stopWebServer(options)
 
 if __name__ == "__main__":
     main()
--- a/testing/mochitest/runtestsremote.py
+++ b/testing/mochitest/runtestsremote.py
@@ -340,13 +340,21 @@ def main():
     dm.mkDir(logParent);
     auto.setRemoteLog(options.remoteLogFile)
     auto.setServerInfo(options.webServer, options.httpPort, options.sslPort)
 
     procName = options.app.split('/')[-1]
     if (dm.processExist(procName)):
       dm.killProcess(procName)
 
-    sys.exit(mochitest.runTests(options))
-    
+    try:
+      retVal = mochitest.runTests(options)
+    except:
+      print "TEST-UNEXPECTED-ERROR | | Exception caught while running tests."
+      mochitest.stopWebServer(options)
+      mochitest.stopWebSocketServer(options)
+      sys.exit(1)
+      
+    sys.exit(retVal)
+        
 if __name__ == "__main__":
     main()