Bug 710445 - Add support for packaging tests in a specific directory. r=gbrown
authorJoel Maher <jmaher@mozilla.com>
Sat, 07 Jan 2012 08:25:05 -0500
changeset 85229 b5686f25b258de3e888e7bf44a9a0be56e6a83ea
parent 85228 32f8d3be2ad1d2250dc3ade7411a3a61ee25bda2
child 85230 a1dc0efef5421356cb0dedeaea04d93f551eb33c
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgbrown
bugs710445
milestone12.0a1
Bug 710445 - Add support for packaging tests in a specific directory. r=gbrown
testing/mochitest/runtestsremote.py
testing/testsuite-targets.mk
--- a/testing/mochitest/runtestsremote.py
+++ b/testing/mochitest/runtestsremote.py
@@ -104,19 +104,24 @@ class RemoteOptions(MochitestOptions):
 
         self.add_option("--pidfile", action = "store",
                     type = "string", dest = "pidFile",
                     help = "name of the pidfile to generate")
         defaults["pidFile"] = ""
 
         self.add_option("--robocop", action = "store",
                     type = "string", dest = "robocop",
-                    help = "use when running robotium tests on native UI")
+                    help = "name of the .ini file containing the list of tests to run")
         defaults["robocop"] = ""
 
+        self.add_option("--robocop-path", action = "store",
+                    type = "string", dest = "robocopPath",
+                    help = "Path to the folder where robocop.apk is located at.  Primarily used for ADB test running")
+        defaults["robocopPath"] = ""
+
         defaults["remoteTestRoot"] = None
         defaults["logFile"] = "mochitest.log"
         defaults["autorun"] = True
         defaults["closeWhenDone"] = True
         defaults["testPath"] = ""
         defaults["app"] = None
 
         self.set_defaults(**defaults)
@@ -165,16 +170,27 @@ class RemoteOptions(MochitestOptions):
             else:
                 options.xrePath = options.utilityPath
 
         if (options.pidFile != ""):
             f = open(options.pidFile, 'w')
             f.write("%s" % os.getpid())
             f.close()
 
+        # Robocop specific options
+        if options.robocop and not os.path.exists(options.robocop):
+            print "ERROR: Unable to find specified manifest '%s'" % options.robocop
+            return None
+        options.robocop = os.path.abspath(options.robocop)
+
+        if options.robocopPath and not os.path.exists(os.path.join(options.robocopPath, 'robocop.apk')):
+            print "ERROR: Unable to find robocop.apk in path '%s'" % options.robocopPath
+            return None
+        options.robocopPath = os.path.abspath(options.robocopPath)
+
         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
@@ -354,35 +370,38 @@ def main():
 
     procName = options.app.split('/')[-1]
     if (dm.processExist(procName)):
         dm.killProcess(procName)
     
     if (options.robocop):
         mp = manifestparser.TestManifest(strict=False)
         # TODO: pull this in dynamically
-        mp.read('robocop.ini')
+        mp.read(options.robocop)
         robocop_tests = mp.active_tests(exists=False)
 
         fHandle = open("robotium.config", "w")
         fHandle.write("profile=%s\n" % (mochitest.remoteProfile))
         fHandle.write("logfile=%s\n" % (options.remoteLogFile))
         fHandle.close()
         deviceRoot = dm.getDeviceRoot()
       
         # Note, we are pushing to /sdcard since we have this location hard coded in robocop
         dm.pushFile("robotium.config", "/sdcard/robotium.config")
         dm.pushFile(os.path.abspath(options.robocop + "/fennec_ids.txt"), "/sdcard/fennec_ids.txt")
         options.extraPrefs.append('robocop.logfile="%s/robocop.log"' % deviceRoot)
 
-        if (options.dm_trans == 'adb'):
-          dm.checkCmd(["install", "-r", os.path.join(options.robocop, "robocop.apk")])
+        if (options.dm_trans == 'adb' and options.robocopPath):
+          dm.checkCmd(["install", "-r", os.path.join(options.robocopPath, "robocop.apk")])
 
         appname = options.app
         for test in robocop_tests:
+            if options.testPath and options.testPath != test['name']:
+                continue
+
             options.app = "am"
             options.browserArgs = ["instrument", "-w", "-e", "class"]
             options.browserArgs.append("%s.tests.%s" % (appname, test['name']))
             options.browserArgs.append("org.mozilla.roboexample.test/android.test.InstrumentationTestRunner")
 
             try:
                 retVal = mochitest.runTests(options)
             except:
--- a/testing/testsuite-targets.mk
+++ b/testing/testsuite-targets.mk
@@ -71,20 +71,20 @@ RUN_MOCHITEST_REMOTE = \
 	rm -f ./$@.log && \
 	$(PYTHON) _tests/testing/mochitest/runtestsremote.py --autorun --close-when-done \
 	  --console-level=INFO --log-file=./$@.log --file-level=INFO $(DM_FLAGS) --dm_trans=$(DM_TRANS) \
 	  --app=$(TEST_PACKAGE_NAME) --deviceIP=${TEST_DEVICE} --xre-path=${MOZ_HOST_BIN} \
 	  $(SYMBOLS_PATH) $(TEST_PATH_ARG) $(EXTRA_TEST_ARGS)
 
 RUN_MOCHITEST_ROBOTIUM = \
   rm -f ./$@.log && \
-  $(PYTHON) _tests/testing/mochitest/runtestsremote.py --robocop ../../../build/mobile/robocop \
+  $(PYTHON) _tests/testing/mochitest/runtestsremote.py --robocop-path build/mobile/robocop \
     --console-level=INFO --log-file=./$@.log --file-level=INFO $(DM_FLAGS) --dm_trans=adb \
     --app=$(TEST_PACKAGE_NAME) --deviceIP=${TEST_DEVICE} --xre-path=${MOZ_HOST_BIN} \
-    $(SYMBOLS_PATH) $(TEST_PATH_ARG) $(EXTRA_TEST_ARGS)
+    --robocop build/mobile/robocop/robocop.ini $(SYMBOLS_PATH) $(TEST_PATH_ARG) $(EXTRA_TEST_ARGS)
 
 ifndef NO_FAIL_ON_TEST_ERRORS
 define CHECK_TEST_ERROR
   @errors=`grep "TEST-UNEXPECTED-" $@.log` ;\
   if test "$$errors" ; then \
 	  echo "$@ failed:"; \
 	  echo "$$errors"; \
 	  exit 1; \