Bug 736105 - robocop does a lot of redundant copying of profile and sleeps, we can cut runtime almost in half. r=gbrown
authorJoel Maher <jmaher@mozilla.com>
Fri, 28 Dec 2012 07:18:22 -0500
changeset 117161 a0bc627d0af77d439c4d3f04c34f0c1c2bbb287f
parent 117160 9119f282e0c0f39525fc5ff7e51aa21c4f4437fc
child 117162 1faf3072fb8bc8d52fc9b0b1b521913903513dbd
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersgbrown
bugs736105
milestone20.0a1
Bug 736105 - robocop does a lot of redundant copying of profile and sleeps, we can cut runtime almost in half. r=gbrown
testing/mochitest/runtestsremote.py
--- a/testing/mochitest/runtestsremote.py
+++ b/testing/mochitest/runtestsremote.py
@@ -3,16 +3,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import sys
 import os
 import time
 import tempfile
 import re
 import traceback
+import shutil
 
 sys.path.insert(0, os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0]))))
 
 from automation import Automation
 from remoteautomation import RemoteAutomation, fennecLogcatFilters
 from runtests import Mochitest
 from runtests import MochitestOptions
 from runtests import MochitestServer
@@ -168,16 +169,18 @@ class RemoteOptions(MochitestOptions):
             options.robocopPath = os.path.abspath(options.robocopPath)
 
         if options.robocopIds != "":
             if not os.path.exists(options.robocopIds):
                 print "ERROR: Unable to find specified IDs file '%s'" % options.robocopIds
                 return None
             options.robocopIds = os.path.abspath(options.robocopIds)
 
+        # allow us to keep original application around for cleanup while running robocop via 'am'
+        options.remoteappname = options.app
         return options
 
     def verifyOptions(self, options, mochitest):
         # since we are reusing verifyOptions, it will exit if App is not found
         temp = options.app
         options.app = sys.argv[0]
         tempPort = options.httpPort
         tempSSL = options.sslPort
@@ -289,37 +292,51 @@ class MochiRemote(Mochitest):
         self.server.stop()
         
     def buildProfile(self, options):
         if self.localProfile:
             options.profilePath = self.localProfile
         manifest = Mochitest.buildProfile(self, options)
         self.localProfile = options.profilePath
         self._dm.removeDir(self.remoteProfile)
+
+        # we do not need this for robotium based tests, lets save a LOT of time
+        if options.robocop:
+            shutil.rmtree(os.path.join(options.profilePath, 'webapps'))
+            shutil.rmtree(os.path.join(options.profilePath, 'extensions', 'staged', 'mochikit@mozilla.org'))
+            shutil.rmtree(os.path.join(options.profilePath, 'extensions', 'staged', 'worker-test@mozilla.org'))
+            shutil.rmtree(os.path.join(options.profilePath, 'extensions', 'staged', 'workerbootstrap-test@mozilla.org'))
+            shutil.rmtree(os.path.join(options.profilePath, 'extensions', 'staged', 'special-powers@mozilla.org'))
+            os.remove(os.path.join(options.profilePath, 'tests.jar'))
+            os.remove(os.path.join(options.profilePath, 'userChrome.css'))
+            os.remove(os.path.join(options.profilePath, 'tests.manifest'))
+
         try:
             self._dm.pushDir(options.profilePath, self.remoteProfile)
         except devicemanager.DMError:
             print "Automation Error: Unable to copy profile to device."
             raise
 
         options.profilePath = self.remoteProfile
         return manifest
     
     def buildURLOptions(self, options, env):
         self.localLog = options.logFile
         options.logFile = self.remoteLog
         options.profilePath = self.localProfile
         env["MOZ_HIDE_RESULTS_TABLE"] = "1"
         retVal = Mochitest.buildURLOptions(self, options, env)
-        #we really need testConfig.js (for browser chrome)
-        try:
-            self._dm.pushDir(options.profilePath, self.remoteProfile)
-        except devicemanager.DMError:
-            print "Automation Error: Unable to copy profile to device."
-            raise
+
+        if not options.robocop:
+            #we really need testConfig.js (for browser chrome)
+            try:
+                self._dm.pushDir(options.profilePath, self.remoteProfile)
+            except devicemanager.DMError:
+                print "Automation Error: Unable to copy profile to device."
+                raise
 
         options.profilePath = self.remoteProfile
         options.logFile = self.localLog
         return retVal
 
     def installChromeFile(self, filename, options):
         parts = options.app.split('/')
         if (parts[0] == options.app):
@@ -492,26 +509,25 @@ def main():
         dm.pushFile(fennec_ids, os.path.join(deviceRoot, "fennec_ids.txt"))
         options.extraPrefs.append('robocop.logfile="%s/robocop.log"' % deviceRoot)
         options.extraPrefs.append('browser.search.suggest.enabled=true')
         options.extraPrefs.append('browser.search.suggest.prompted=true')
 
         if (options.dm_trans == 'adb' and options.robocopPath):
           dm._checkCmd(["install", "-r", os.path.join(options.robocopPath, "robocop.apk")])
 
-        appname = options.app
         retVal = None
         for test in robocop_tests:
             if options.testPath and options.testPath != test['name']:
                 continue
 
             options.app = "am"
             options.browserArgs = ["instrument", "-w", "-e", "deviceroot", deviceRoot, "-e", "class"]
-            options.browserArgs.append("%s.tests.%s" % (appname, test['name']))
-            options.browserArgs.append("org.mozilla.roboexample.test/%s.FennecInstrumentationTestRunner" % appname)
+            options.browserArgs.append("%s.tests.%s" % (options.remoteappname, test['name']))
+            options.browserArgs.append("org.mozilla.roboexample.test/%s.FennecInstrumentationTestRunner" % options.remoteappname)
 
             try:
                 dm.recordLogcat()
                 result = mochitest.runTests(options)
                 if result != 0:
                     print "ERROR: runTests() exited with code %s" % result
                     mochitest.printDeviceInfo()
                 # Ensure earlier failures aren't overwritten by success on this run