From 0a9a9e30db16e96e0730f4c349ab361980f7e163 Mon Sep 17 00:00:00 2001 From: Nick Alexander Date: Fri, 26 Sep 2014 11:44:58 -0700 Subject: [PATCH] Bug 1069648 - Add instrumentation manifests to moz.build. r=ted These manifests are special in that they don't package their test files into the test package. Each test listed in an instrumentation manifest serves as an identifier rather than a file. --HG-- extra : rebase_source : 0321528a2dc380e57b824746efbcf61d295204a9 --- .../background/junit3/instrumentation.ini | 47 +++++++++++++++++++ .../android/tests/background/junit3/moz.build | 2 + .../tests/browser/junit3/instrumentation.ini | 10 ++++ mobile/android/tests/browser/junit3/moz.build | 2 + python/mozbuild/mozbuild/frontend/context.py | 4 ++ python/mozbuild/mozbuild/frontend/emitter.py | 34 ++++++++------ .../instrumentation.ini | 1 + .../mochitest.ini | 1 + .../test-manifests-package-tests/mochitest.js | 0 .../test-manifests-package-tests/moz.build | 10 ++++ .../not_packaged.java | 0 .../test/backend/test_recursivemake.py | 31 ++++++++++++ 12 files changed, 127 insertions(+), 15 deletions(-) create mode 100644 mobile/android/tests/background/junit3/instrumentation.ini create mode 100644 mobile/android/tests/browser/junit3/instrumentation.ini create mode 100644 python/mozbuild/mozbuild/test/backend/data/test-manifests-package-tests/instrumentation.ini create mode 100644 python/mozbuild/mozbuild/test/backend/data/test-manifests-package-tests/mochitest.ini create mode 100644 python/mozbuild/mozbuild/test/backend/data/test-manifests-package-tests/mochitest.js create mode 100644 python/mozbuild/mozbuild/test/backend/data/test-manifests-package-tests/moz.build create mode 100644 python/mozbuild/mozbuild/test/backend/data/test-manifests-package-tests/not_packaged.java diff --git a/mobile/android/tests/background/junit3/instrumentation.ini b/mobile/android/tests/background/junit3/instrumentation.ini new file mode 100644 index 000000000000..fd1aa22f3a1e --- /dev/null +++ b/mobile/android/tests/background/junit3/instrumentation.ini @@ -0,0 +1,47 @@ +[DEFAULT] +subsuite = background + +[src/common/TestAndroidLogWriters.java] +[src/common/TestBrowserContractHelpers.java] +[src/common/TestDateUtils.java] +[src/common/TestUtils.java] +[src/common/TestWaitHelper.java] +[src/db/TestAndroidBrowserBookmarksRepository.java] +[src/db/TestAndroidBrowserHistoryDataExtender.java] +[src/db/TestAndroidBrowserHistoryRepository.java] +[src/db/TestBookmarks.java] +[src/db/TestCachedSQLiteOpenHelper.java] +[src/db/TestClientsDatabase.java] +[src/db/TestClientsDatabaseAccessor.java] +[src/db/TestFennecTabsRepositorySession.java] +[src/db/TestFennecTabsStorage.java] +[src/db/TestFormHistoryRepositorySession.java] +[src/db/TestPasswordsRepository.java] +[src/fxa/TestBrowserIDKeyPairGeneration.java] +[src/fxa/authenticator/TestAccountPickler.java] +[src/healthreport/TestEnvironmentBuilder.java] +[src/healthreport/TestEnvironmentV1HashAppender.java] +[src/healthreport/TestHealthReportBroadcastService.java] +[src/healthreport/TestHealthReportDatabaseStorage.java] +[src/healthreport/TestHealthReportGenerator.java] +[src/healthreport/TestHealthReportProvider.java] +[src/healthreport/TestHealthReportSQLiteOpenHelper.java] +[src/healthreport/TestProfileInformationCache.java] +[src/healthreport/prune/TestHealthReportPruneService.java] +[src/healthreport/prune/TestPrunePolicyDatabaseStorage.java] +[src/healthreport/upload/TestAndroidSubmissionClient.java] +[src/healthreport/upload/TestHealthReportUploadService.java] +[src/nativecode/test/TestNativeCrypto.java] +[src/sync/TestAccountPickler.java] +[src/sync/TestClientsStage.java] +[src/sync/TestConfigurationMigrator.java] +[src/sync/TestResetting.java] +[src/sync/TestSendTabData.java] +[src/sync/TestStoreTracking.java] +[src/sync/TestSyncAccounts.java] +[src/sync/TestSyncAuthenticatorService.java] +[src/sync/TestSyncConfiguration.java] +[src/sync/TestTabsRecord.java] +[src/sync/TestUpgradeRequired.java] +[src/sync/TestWebURLFinder.java] +[src/telemetry/TestTelemetryRecorder.java] diff --git a/mobile/android/tests/background/junit3/moz.build b/mobile/android/tests/background/junit3/moz.build index 8fb45ca79cb3..38b05ee612fe 100644 --- a/mobile/android/tests/background/junit3/moz.build +++ b/mobile/android/tests/background/junit3/moz.build @@ -21,3 +21,5 @@ main.referenced_projects += ['Fennec'] main.add_classpathentry('src', SRCDIR + '/src', dstdir='src/org/mozilla/gecko/background') + +ANDROID_INSTRUMENTATION_MANIFESTS += ['instrumentation.ini'] diff --git a/mobile/android/tests/browser/junit3/instrumentation.ini b/mobile/android/tests/browser/junit3/instrumentation.ini new file mode 100644 index 000000000000..9e2eb167f76a --- /dev/null +++ b/mobile/android/tests/browser/junit3/instrumentation.ini @@ -0,0 +1,10 @@ +[DEFAULT] +subsuite = browser + +[src/TestDistribution.java] +[src/TestGeckoSharedPrefs.java] +[src/TestImageDownloader.java] +[src/TestJarReader.java] +[src/TestRawResource.java] +[src/TestSuggestedSites.java] +[src/TestTopSitesCursorWrapper.java] diff --git a/mobile/android/tests/browser/junit3/moz.build b/mobile/android/tests/browser/junit3/moz.build index 2e1935031e91..e5cdd8da2d18 100644 --- a/mobile/android/tests/browser/junit3/moz.build +++ b/mobile/android/tests/browser/junit3/moz.build @@ -37,3 +37,5 @@ main.referenced_projects += ['Fennec'] main.add_classpathentry('src', SRCDIR + '/src', dstdir='src/org/mozilla/gecko') + +ANDROID_INSTRUMENTATION_MANIFESTS += ['instrumentation.ini'] diff --git a/python/mozbuild/mozbuild/frontend/context.py b/python/mozbuild/mozbuild/frontend/context.py index a460071a131e..9a403461d318 100644 --- a/python/mozbuild/mozbuild/frontend/context.py +++ b/python/mozbuild/mozbuild/frontend/context.py @@ -821,6 +821,10 @@ VARIABLES = { These are commonly named crashtests.list. """, None), + 'ANDROID_INSTRUMENTATION_MANIFESTS': (StrictOrderingOnAppendList, list, + """List of manifest files defining Android instrumentation tests. + """, None), + 'METRO_CHROME_MANIFESTS': (StrictOrderingOnAppendList, list, """List of manifest files defining metro browser chrome tests. """, None), diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py index 122e8cf2a78b..7b731e048852 100644 --- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -750,28 +750,32 @@ class TreeMetadataEmitter(LoggingMixin): # Keys are variable prefixes and values are tuples describing how these # manifests should be handled: # - # (flavor, install_prefix, active) + # (flavor, install_prefix, active, package_tests) # # flavor identifies the flavor of this test. # install_prefix is the path prefix of where to install the files in # the tests directory. # active indicates whether to filter out inactive tests from the # manifest. + # package_tests indicates whether to package test files into the test + # package; suites that compile the test files should not install + # them into the test package. # # We ideally don't filter out inactive tests. However, not every test # harness can yet deal with test filtering. Once all harnesses can do # this, this feature can be dropped. test_manifests = dict( - A11Y=('a11y', 'testing/mochitest', 'a11y', True), - BROWSER_CHROME=('browser-chrome', 'testing/mochitest', 'browser', True), - JETPACK_PACKAGE=('jetpack-package', 'testing/mochitest', 'jetpack-package', True), - JETPACK_ADDON=('jetpack-addon', 'testing/mochitest', 'jetpack-addon', True), - METRO_CHROME=('metro-chrome', 'testing/mochitest', 'metro', True), - MOCHITEST=('mochitest', 'testing/mochitest', 'tests', True), - MOCHITEST_CHROME=('chrome', 'testing/mochitest', 'chrome', True), - MOCHITEST_WEBAPPRT_CHROME=('webapprt-chrome', 'testing/mochitest', 'webapprtChrome', True), - WEBRTC_SIGNALLING_TEST=('steeplechase', 'steeplechase', '.', True), - XPCSHELL_TESTS=('xpcshell', 'xpcshell', '.', False), + A11Y=('a11y', 'testing/mochitest', 'a11y', True, True), + BROWSER_CHROME=('browser-chrome', 'testing/mochitest', 'browser', True, True), + ANDROID_INSTRUMENTATION=('instrumentation', 'instrumentation', '.', False, False), + JETPACK_PACKAGE=('jetpack-package', 'testing/mochitest', 'jetpack-package', True, True), + JETPACK_ADDON=('jetpack-addon', 'testing/mochitest', 'jetpack-addon', True, False), + METRO_CHROME=('metro-chrome', 'testing/mochitest', 'metro', True, True), + MOCHITEST=('mochitest', 'testing/mochitest', 'tests', True, True), + MOCHITEST_CHROME=('chrome', 'testing/mochitest', 'chrome', True, True), + MOCHITEST_WEBAPPRT_CHROME=('webapprt-chrome', 'testing/mochitest', 'webapprtChrome', True, True), + WEBRTC_SIGNALLING_TEST=('steeplechase', 'steeplechase', '.', True, True), + XPCSHELL_TESTS=('xpcshell', 'xpcshell', '.', False, True), ) for prefix, info in test_manifests.items(): @@ -823,7 +827,7 @@ class TreeMetadataEmitter(LoggingMixin): return sub def _process_test_manifest(self, context, info, manifest_path): - flavor, install_root, install_subdir, filter_inactive = info + flavor, install_root, install_subdir, filter_inactive, package_tests = info manifest_path = mozpath.normpath(manifest_path) path = mozpath.normpath(mozpath.join(context.srcdir, manifest_path)) @@ -930,9 +934,9 @@ class TreeMetadataEmitter(LoggingMixin): for test in filtered: obj.tests.append(test) - # Jetpack add-on tests are generated directly in the test - # directory - if flavor != 'jetpack-addon': + # Some test files are compiled and should not be copied into the + # test package. They function as identifiers rather than files. + if package_tests: obj.installs[mozpath.normpath(test['path'])] = \ (mozpath.join(out_dir, test['relpath']), True) diff --git a/python/mozbuild/mozbuild/test/backend/data/test-manifests-package-tests/instrumentation.ini b/python/mozbuild/mozbuild/test/backend/data/test-manifests-package-tests/instrumentation.ini new file mode 100644 index 000000000000..03d4f794e226 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/test-manifests-package-tests/instrumentation.ini @@ -0,0 +1 @@ +[not_packaged.java] diff --git a/python/mozbuild/mozbuild/test/backend/data/test-manifests-package-tests/mochitest.ini b/python/mozbuild/mozbuild/test/backend/data/test-manifests-package-tests/mochitest.ini new file mode 100644 index 000000000000..009b2b22396b --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/test-manifests-package-tests/mochitest.ini @@ -0,0 +1 @@ +[mochitest.js] diff --git a/python/mozbuild/mozbuild/test/backend/data/test-manifests-package-tests/mochitest.js b/python/mozbuild/mozbuild/test/backend/data/test-manifests-package-tests/mochitest.js new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/python/mozbuild/mozbuild/test/backend/data/test-manifests-package-tests/moz.build b/python/mozbuild/mozbuild/test/backend/data/test-manifests-package-tests/moz.build new file mode 100644 index 000000000000..82dba29dc583 --- /dev/null +++ b/python/mozbuild/mozbuild/test/backend/data/test-manifests-package-tests/moz.build @@ -0,0 +1,10 @@ +# Any copyright is dedicated to the Public Domain. +# http://creativecommons.org/publicdomain/zero/1.0/ + +MOCHITEST_MANIFESTS += [ + 'mochitest.ini', +] + +ANDROID_INSTRUMENTATION_MANIFESTS += [ + 'instrumentation.ini', +] diff --git a/python/mozbuild/mozbuild/test/backend/data/test-manifests-package-tests/not_packaged.java b/python/mozbuild/mozbuild/test/backend/data/test-manifests-package-tests/not_packaged.java new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py index c25b4bdcdf61..dad466f16ba4 100644 --- a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py +++ b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py @@ -687,6 +687,37 @@ class TestRecursiveMakeBackend(BackendTester): stem = '%s/android_eclipse/%s' % (env.topobjdir, project_name) self.assertIn(command_template % (stem, stem), lines) + def test_install_manifests_package_tests(self): + """Ensure test suites honor package_tests=False.""" + env = self._consume('test-manifests-package-tests', RecursiveMakeBackend) + + tests_dir = mozpath.join(env.topobjdir, '_tests') + + all_tests_path = mozpath.join(env.topobjdir, 'all-tests.json') + self.assertTrue(os.path.exists(all_tests_path)) + + with open(all_tests_path, 'rt') as fh: + o = json.load(fh) + + self.assertIn('mochitest.js', o) + self.assertIn('not_packaged.java', o) + + man_dir = mozpath.join(env.topobjdir, '_build_manifests', 'install') + self.assertTrue(os.path.isdir(man_dir)) + + full = mozpath.join(man_dir, 'tests') + self.assertTrue(os.path.exists(full)) + + m = InstallManifest(path=full) + + # Only mochitest.js should be in the install manifest. + self.assertTrue('testing/mochitest/tests/mochitest.js' in m) + + # The path is odd here because we do not normalize at test manifest + # processing time. This is a fragile test because there's currently no + # way to iterate the manifest. + self.assertFalse('instrumentation/./not_packaged.java' in m) + if __name__ == '__main__': main()