Bug 1170332 - Fix |mach robocop SINGLE_TEST|. r=ahal,gbrown
authorNick Alexander <nalexander@mozilla.com>
Mon, 01 Jun 2015 14:45:48 -0700
changeset 266213 0d93a77bb15326125395894d9f36c61f71fb5338
parent 266212 8ff42f8c288c9e3da9a21b7d695bf6b33e1032f7
child 266214 da1d9b5dda90a4e5f1ee463aa23fad530430a388
push id8157
push userjlund@mozilla.com
push dateMon, 29 Jun 2015 20:36:23 +0000
treeherdermozilla-aurora@d480e05bd276 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal, gbrown
bugs1170332
milestone41.0a1
Bug 1170332 - Fix |mach robocop SINGLE_TEST|. r=ahal,gbrown This patch declares robocop.ini an instrumentation manifest. It's not currently possible to declare tests that don't correspond to files, so we include the .java extension. (This could be revisited.) In |mach robocop|, we use the generic test resolving infrastructure to select the 'instrumentation'/'robocop' flavor/subsuite tests. In |runtestsremote.py|, we fall back to robocop.ini, as we always have.
mobile/android/tests/browser/robocop/robocop.ini
mobile/android/tests/moz.build
testing/mochitest/mach_commands.py
testing/mochitest/runtestsremote.py
--- a/mobile/android/tests/browser/robocop/robocop.ini
+++ b/mobile/android/tests/browser/robocop/robocop.ini
@@ -1,189 +1,192 @@
-[testGeckoProfile]
-# [test_bug720538] # disabled on fig - bug 897072
-[testAboutPage]
+[DEFAULT]
+subsuite = robocop
+
+[testGeckoProfile.java]
+# [test_bug720538.java] # disabled on fig - bug 897072
+[testAboutPage.java]
 # disabled on Android 2.3; bug 975187
 skip-if = android_version == "10"
-[testAboutPasswords]
-[testAddonManager]
+[testAboutPasswords.java]
+[testAddonManager.java]
 # disabled on 2.3: bug 941624, bug 1063509, bug 1073374, bug 1087221, bug 1088023, bug 1088027, bug 1090206; on 4.3, bug 1144918
 skip-if = android_version == "10" || android_version == "18"
-[testAddSearchEngine]
+[testAddSearchEngine.java]
 # disabled on Android 2.3, bug 979552; on 4.3, bug 1120759
 skip-if = android_version == "10" || android_version == "18"
-[testAdobeFlash]
+[testAdobeFlash.java]
 # disabled on 4.3, bug 1146420
 skip-if = android_version == "18"
-[testANRReporter]
-[testAppConstants]
-[testAwesomebar]
-[testAxisLocking]
+[testANRReporter.java]
+[testAppConstants.java]
+[testAwesomebar.java]
+[testAxisLocking.java]
 # disabled on 4.3, bug 1144874
 skip-if = android_version == "18"
-# [testBookmark] # see bug 915350
-[testBookmarksPanel]
+# [testBookmark.java] # see bug 915350
+[testBookmarksPanel.java]
 # disabled on 2.3, bug 979615; on 4.3, bug 987930
 skip-if = android_version == "10" || android_version == "18"
-[testBookmarkFolders]
+[testBookmarkFolders.java]
 # disabled on Android 2.3, bug 979552; on 4.3, bug 1144921
 skip-if = android_version == "10" || android_version == "18"
-# [testBookmarklets] # see bug 915350
-# [testBookmarkKeyword] # see bug 915350
-[testBrowserProvider]
-[testBrowserSearchVisibility]
-[testClearPrivateData]
+# [testBookmarklets.java] # see bug 915350
+# [testBookmarkKeyword.java] # see bug 915350
+[testBrowserProvider.java]
+[testBrowserSearchVisibility.java]
+[testClearPrivateData.java]
 # disabled on 2.3, bug 948591; on 4.3, bug 1000643
 skip-if = android_version == "10" || android_version == "18"
-[testDBUtils]
-[testDistribution]
-[testDoorHanger]
+[testDBUtils.java]
+[testDistribution.java]
+[testDoorHanger.java]
 # disabled on 2.3, bug 1085609; on 4.3, bug 1144924
 skip-if = android_version == "10" || android_version == "18"
-[testFilterOpenTab]
-# [testFindInPage] # bug 1128287
-[testFlingCorrectness]
+[testFilterOpenTab.java]
+# [testFindInPage.java] # bug 1128287
+[testFlingCorrectness.java]
 # disabled on 4.3, bug 1144874
 skip-if = android_version == "18"
-[testFormHistory]
-[testGetUserMedia]
+[testFormHistory.java]
+[testGetUserMedia.java]
 # failures across the board, bug 1092202 & bug 1144926
 skip-if = true
-# [testHistory] # see bug 915350
-[testHomeBanner]
-[testImportFromAndroid]
+# [testHistory.java] # see bug 915350
+[testHomeBanner.java]
+[testImportFromAndroid.java]
 # disabled on 2.3 and 4.3 bug 979552
 skip-if = android_version == "10" || android_version == "18"
-[testInputUrlBar]
+[testInputUrlBar.java]
 # disabled on 2.3 bug 1165511
 skip-if = android_version == "10"
-[testJarReader]
-[testLinkContextMenu]
+[testJarReader.java]
+[testLinkContextMenu.java]
 # disabled on 4.3, bug 1083666
 skip-if = android_version == "18"
-# [testHomeListsProvider] # see bug 952310
-[testHomeProvider]
-[testLoad]
-[testMailToContextMenu]
-# [testMasterPassword] disabled for being finicky, see bug 1033013
+# [testHomeListsProvider.java] # see bug 952310
+[testHomeProvider.java]
+[testLoad.java]
+[testMailToContextMenu.java]
+# [testMasterPassword.java] disabled for being finicky, see bug 1033013
 # disabled on 2.3; bug 979603
 # disabled on 4.0; bug 1006242
 # skip-if = android_version == "10" || android_version == "15"
-[testNewTab]
+[testNewTab.java]
 # disabled on 4.3, bug 1145851
 skip-if = android_version == "18"
-[testPanCorrectness]
+[testPanCorrectness.java]
 # disabled on 4.3, bug 1144874
 skip-if = android_version == "18"
-# [testPasswordEncrypt] # see bug 824067
-[testPasswordProvider]
-# [testPermissions] # see bug 757475
-[testPictureLinkContextMenu]
+# [testPasswordEncrypt.java] # see bug 824067
+[testPasswordProvider.java]
+# [testPermissions.java] # see bug 757475
+[testPictureLinkContextMenu.java]
 # disabled on 4.3, bug 1031496
 skip-if = android_version == "18"
-[testPrefsObserver]
-[testPrivateBrowsing]
-[testPromptGridInput]
+[testPrefsObserver.java]
+[testPrivateBrowsing.java]
+[testPromptGridInput.java]
 # bug 1001657 for 2.3 and 4.3
 skip-if = android_version == "10" || android_version == "18"
-[testReadingListProvider]
-[testSearchHistoryProvider]
-[testSearchSuggestions]
+[testReadingListProvider.java]
+[testSearchHistoryProvider.java]
+[testSearchSuggestions.java]
 # disabled on 2.3, bug 907768; on 4.3, bug 1145867
 skip-if = android_version == "10" || android_version == "18"
-[testSessionOOMSave]
+[testSessionOOMSave.java]
 # disabled on 2.3, bug 945395; on 4.3, bug 1144888
 skip-if = android_version == "10" || android_version == "18"
-[testSessionOOMRestore]
+[testSessionOOMRestore.java]
 # disabled on Android 2.3, bug 979600; on 4.3, bug 1145879
 skip-if = android_version == "10" || android_version == "18"
-[testSettingsMenuItems]
+[testSettingsMenuItems.java]
 # disabled on Android 2.3, bug 979552; on 4.3, bug 1144898
 skip-if = android_version == "10" || android_version == "18"
-# [testShareLink] # see bug 915897
-[testSystemPages]
+# [testShareLink.java] # see bug 915897
+[testSystemPages.java]
 # disabled on 2.3, bug 979603; on 4.3, bug 1142811
 skip-if = android_version == "10" || android_version == "18"
-# [testThumbnails] # see bug 813107
-[testTitleBar]
+# [testThumbnails.java] # see bug 813107
+[testTitleBar.java]
 # disabled on Android 2.3, bug 979552; on 4.3, bug 1145881
 skip-if = android_version == "10" || android_version == "18"
-# [testVkbOverlap] # see bug 907274
+# [testVkbOverlap.java] # see bug 907274
 
 # Using JavascriptTest
-[testAccounts]
-[testAndroidLog]
-[testBrowserDiscovery]
+[testAccounts.java]
+[testAndroidLog.java]
+[testBrowserDiscovery.java]
 # disabled on 4.3, bug 1158384
 skip-if = android_version == "18"
-[testDebuggerServer]
-[testDeviceSearchEngine]
-[testFilePicker]
-[testHistoryService]
+[testDebuggerServer.java]
+[testDeviceSearchEngine.java]
+[testFilePicker.java]
+[testHistoryService.java]
 # disabled on 4.3, bug 1116036
 skip-if = android_version == "18"
-[testJNI]
-# [testMozPay] # see bug 945675
-[testMigrateUI]
-[testNetworkManager]
-[testOfflinePage]
-[testOrderedBroadcast]
-[testOSLocale]
+[testJNI.java]
+# [testMozPay.java] # see bug 945675
+[testMigrateUI.java]
+[testNetworkManager.java]
+[testOfflinePage.java]
+[testOrderedBroadcast.java]
+[testOSLocale.java]
 # disabled on 2.3 and 4.3: Bug 1124494
 skip-if = android_version == "10" || android_version == "18"
-[testReaderView]
-[testReadingListCache]
-[testResourceSubstitutions]
-[testRestrictedProfiles]
-[testSessionFormData]
-[testSharedPreferences]
-[testSimpleDiscovery]
-[testTrackingProtection]
+[testReaderView.java]
+[testReadingListCache.java]
+[testResourceSubstitutions.java]
+[testRestrictedProfiles.java]
+[testSessionFormData.java]
+[testSharedPreferences.java]
+[testSimpleDiscovery.java]
+[testTrackingProtection.java]
 # disabled on 4.3, bug 1158363
 skip-if = android_version == "18"
-[testUITelemetry]
-[testVideoControls]
+[testUITelemetry.java]
+[testVideoControls.java]
 # disabled on Android 2.3 due to video playback issues, bug 1088038; on 4.3, bug 1098532
 skip-if = android_version == "10" || android_version == "18"
-[testVideoDiscovery]
+[testVideoDiscovery.java]
 
 # Used for Talos, please don't use in mochitest
-#[testCheck2]
+#[testCheck2.java]
 
 # Using UITest
-#[testAboutHomePageNavigation] # see bug 947550, bug 979038 and bug 977952
-[testAboutHomeVisibility]
+#[testAboutHomePageNavigation.java] # see bug 947550, bug 979038 and bug 977952
+[testAboutHomeVisibility.java]
 # disabled on Android 2.3; bug 946656
 skip-if = android_version == "10"
-[testAppMenuPathways]
+[testAppMenuPathways.java]
 # disabled on 4.3, bug 1158005
 skip-if = android_version == "18"
-[testBackButtonInEditMode]
-[testEventDispatcher]
-[testGeckoRequest]
-[testInputConnection]
+[testBackButtonInEditMode.java]
+[testEventDispatcher.java]
+[testGeckoRequest.java]
+[testInputConnection.java]
 # disabled on Android 2.3, 4.3; bug 1025968
 skip-if = android_version == "10" || android_version == "18"
-[testJavascriptBridge]
-[testNativeCrypto]
-[testReaderModeTitle]
-[testSessionHistory]
+[testJavascriptBridge.java]
+[testNativeCrypto.java]
+[testReaderModeTitle.java]
+[testSessionHistory.java]
 # disabled on Android 4.3, bug 1144879
 skip-if = android_version == "18"
-[testStateWhileLoading]
+[testStateWhileLoading.java]
 
-[testSelectionCarets]
+[testSelectionCarets.java]
 # testSelectionHandler disabled on Android 2.3 by trailing skip-if, due to bug 980074
 # also disabled on Android 4.3, bug 1144882
-[testSelectionHandler]
+[testSelectionHandler.java]
 skip-if = android_version == "10" || android_version == "18"
 
 # testInputSelections disabled on Android 2.3 by trailing skip-if, due to bug 980074
-[testInputSelections]
+[testInputSelections.java]
 skip-if = android_version == "10"
 
 # testTextareaSelections disabled on Android 2.3 by trailing skip-if, due to bug 980074
-[testTextareaSelections]
+[testTextareaSelections.java]
 skip-if = android_version == "10"
 
 # testStumblerSetting disabled on Android 4.3, bug 1145846
-[testStumblerSetting]
+[testStumblerSetting.java]
 skip-if = android_version == "10" || android_version == "18"
--- a/mobile/android/tests/moz.build
+++ b/mobile/android/tests/moz.build
@@ -3,8 +3,10 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 TEST_DIRS += [
     'background',
     'browser',
 ]
+
+ANDROID_INSTRUMENTATION_MANIFESTS += ['browser/robocop/robocop.ini']
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -570,37 +570,41 @@ class MachCommands(MachCommandBase):
 
 @CommandProvider
 class RobocopCommands(MachCommandBase):
 
     @Command('robocop', category='testing',
              conditions=[conditions.is_android],
              description='Run a Robocop test.',
              parser=setup_argument_parser)
-    @CommandArgument(
-        'test_path',
-        default=None,
-        nargs='?',
-        metavar='TEST',
-        help='Test to run. Can be specified as a Robocop test name (like "testLoad"), '
-        'or omitted. If omitted, the entire test suite is executed.')
-    def run_robocop(self, test_path, **kwargs):
+    @CommandArgument('test_paths', nargs='*', metavar='TEST', default=None,
+                     help='Test to run. Can be a single Robocop test file (like "testLoad.java") '
+                          ' or a directory of tests '
+                          '(to run recursively). If omitted, the entire Robocop suite is run.')
+    def run_robocop(self, test_paths, **kwargs):
         if not kwargs.get('robocopIni'):
             kwargs['robocopIni'] = os.path.join(self.topobjdir, '_tests', 'testing',
                                                 'mochitest', 'robocop.ini')
 
         if not kwargs.get('robocopApk'):
             kwargs['robocopApk'] = os.path.join(self.topobjdir, 'build', 'mobile',
                                                 'robocop', 'robocop-debug.apk')
 
-        if isinstance(test_path, basestring):
-            test_path = [test_path]
+        from mozbuild.controller.building import BuildDriver
+        self._ensure_state_subdir_exists('.')
+
+        driver = self._spawn(BuildDriver)
+        driver.install_tests(remove=False)
+
+        from mozbuild.testing import TestResolver
+        resolver = self._spawn(TestResolver)
+        tests = list(resolver.resolve_tests(paths=test_paths, cwd=self._mach_context.cwd,
+            flavor='instrumentation', subsuite='robocop'))
 
         mochitest = self._spawn(MochitestRunner)
-        tests = mochitest.resolve_tests(test_path, cwd=self._mach_context.cwd)
         return mochitest.run_android_test(self._mach_context, tests, 'robocop', **kwargs)
 
 
 def REMOVED(cls):
     """Command no longer exists! Use |mach mochitest| instead.
 
     The |mach mochitest| command will automatically detect which flavors and
     subsuites exist in a given directory. If desired, flavors and subsuites
--- a/testing/mochitest/runtestsremote.py
+++ b/testing/mochitest/runtestsremote.py
@@ -516,19 +516,21 @@ def run_test_harness(options):
     dm.killProcess(procName)
 
     if options.robocopIni != "":
         # turning buffering off as it's not used in robocop
         message_logger.buffering = False
 
         # sut may wait up to 300 s for a robocop am process before returning
         dm.default_timeout = 320
-        mp = TestManifest(strict=False)
-        # TODO: pull this in dynamically
-        mp.read(options.robocopIni)
+        if isinstance(options.manifestFile, TestManifest):
+            mp = options.manifestFile
+        else:
+            mp = TestManifest(strict=False)
+            mp.read(options.robocopIni)
 
         filters = []
         if options.totalChunks:
             filters.append(
                 chunk_by_slice(options.thisChunk, options.totalChunks))
         robocop_tests = mp.active_tests(exists=False, filters=filters, **mozinfo.info)
 
         options.extraPrefs.append('browser.search.suggest.enabled=true')
@@ -573,17 +575,17 @@ def run_test_harness(options):
                 "-w",
                 "-e",
                 "deviceroot",
                 deviceRoot,
                 "-e",
                 "class"]
             options.browserArgs.append(
                 "org.mozilla.gecko.tests.%s" %
-                test['name'])
+                test['name'].split('.java')[0])
             options.browserArgs.append(
                 "org.mozilla.roboexample.test/org.mozilla.gecko.FennecInstrumentationTestRunner")
             mochitest.nsprLogName = "nspr-%s.log" % test['name']
 
             # If the test is for checking the import from bookmarks then make
             # sure there is data to import
             if test['name'] == "testImportFromAndroid":