Bug 1460912 - [reftest] Use base profiles in reftest
This moves reftest-preferences.js to:
testing/profiles/reftest/user.js
Developers can also now add extensions to:
testing/profiles/reftest/extensions
MozReview-Commit-ID: IVLsT5MWtcJ
--- a/layout/tools/reftest/moz.build
+++ b/layout/tools/reftest/moz.build
@@ -15,17 +15,16 @@ FINAL_TARGET_PP_FILES += ['install.rdf']
FINAL_TARGET_FILES += ['bootstrap.js']
TEST_HARNESS_FILES.reftest += [
'/build/mobile/remoteautomation.py',
'/build/pgo/server-locations.txt',
'/testing/mochitest/server.js',
'mach_test_package_commands.py',
'output.py',
- 'reftest-preferences.js',
'reftestcommandline.py',
'remotereftest.py',
'runreftest.py',
]
TEST_HARNESS_FILES.reftest.chrome += [
'chrome/binding.xml',
'chrome/userContent.css',
--- a/layout/tools/reftest/runreftest.py
+++ b/layout/tools/reftest/runreftest.py
@@ -277,19 +277,71 @@ class RefTest(object):
:param profile_to_clone: Path to a profile to use as the basis for the
test profile
:param prefs: Extra preferences to set in the profile
"""
locations = mozprofile.permissions.ServerLocations()
locations.add_host(server, scheme='http', port=port)
locations.add_host(server, scheme='https', port=port)
- # Set preferences for communication between our command line arguments
- # and the reftest harness. Preferences that are required for reftest
- # to work should instead be set in reftest-preferences.js .
+ sandbox_whitelist_paths = options.sandboxReadWhitelist
+ if (platform.system() == "Linux" or
+ platform.system() in ("Windows", "Microsoft")):
+ # Trailing slashes are needed to indicate directories on Linux and Windows
+ sandbox_whitelist_paths = map(lambda p: os.path.join(p, ""),
+ sandbox_whitelist_paths)
+
+ addons = []
+ if not self.use_marionette:
+ addons.append(options.reftestExtensionPath)
+
+ if options.specialPowersExtensionPath is not None:
+ if not self.use_marionette:
+ addons.append(options.specialPowersExtensionPath)
+
+ # Install distributed extensions, if application has any.
+ distExtDir = os.path.join(options.app[:options.app.rfind(os.sep)],
+ "distribution", "extensions")
+ if os.path.isdir(distExtDir):
+ for f in os.listdir(distExtDir):
+ addons.append(os.path.join(distExtDir, f))
+
+ # Install custom extensions.
+ for f in options.extensionsToInstall:
+ addons.append(self.getFullPath(f))
+
+ kwargs = {'addons': addons,
+ 'locations': locations,
+ 'whitelistpaths': sandbox_whitelist_paths}
+ if profile_to_clone:
+ profile = mozprofile.Profile.clone(profile_to_clone, **kwargs)
+ else:
+ profile = mozprofile.Profile(**kwargs)
+
+ # First set prefs from the base profiles under testing/profiles.
+ profile_data_dir = os.path.join(SCRIPT_DIRECTORY, 'profile_data')
+
+ # If possible, read profile data from topsrcdir. This prevents us from
+ # requiring a re-build to pick up newly added extensions in the
+ # <profile>/extensions directory.
+ if build_obj:
+ path = os.path.join(build_obj.topsrcdir, 'testing', 'profiles')
+ if os.path.isdir(path):
+ profile_data_dir = path
+
+ with open(os.path.join(profile_data_dir, 'profiles.json'), 'r') as fh:
+ base_profiles = json.load(fh)['reftest']
+
+ for name in base_profiles:
+ path = os.path.join(profile_data_dir, name)
+ profile.merge(path)
+
+ # Second set preferences for communication between our command line
+ # arguments and the reftest harness. Preferences that are required for
+ # reftest to work should instead be set under srcdir/testing/profiles.
prefs = prefs or {}
prefs['reftest.timeout'] = options.timeout * 1000
if options.logFile:
prefs['reftest.logFile'] = options.logFile
if options.ignoreWindowSize:
prefs['reftest.ignoreWindowSize'] = True
if options.shuffle:
prefs['reftest.shuffle'] = True
@@ -301,16 +353,25 @@ class RefTest(object):
prefs['reftest.verify'] = True
if options.cleanupCrashes:
prefs['reftest.cleanupPendingCrashes'] = True
prefs['reftest.focusFilterMode'] = options.focusFilterMode
prefs['reftest.logLevel'] = options.log_tbpl_level or 'info'
prefs['reftest.suite'] = options.suite
prefs['reftest.runSlower'] = options.runSlower
+ # Set tests to run or manifests to parse.
+ if tests:
+ testlist = os.path.join(profile.profile, 'reftests.json')
+ with open(testlist, 'w') as fh:
+ json.dump(tests, fh)
+ prefs['reftest.tests'] = testlist
+ elif manifests:
+ prefs['reftest.manifests'] = json.dumps(manifests)
+
# Unconditionally update the e10s pref.
if options.e10s:
prefs['browser.tabs.remote.autostart'] = True
else:
prefs['browser.tabs.remote.autostart'] = False
if not self.run_by_manifest:
if options.totalChunks:
@@ -318,86 +379,42 @@ class RefTest(object):
if options.thisChunk:
prefs['reftest.thisChunk'] = options.thisChunk
# Bug 1262954: For winXP + e10s disable acceleration
if platform.system() in ("Windows", "Microsoft") and \
'5.1' in platform.version() and options.e10s:
prefs['layers.acceleration.disabled'] = True
- sandbox_whitelist_paths = options.sandboxReadWhitelist
- if (platform.system() == "Linux" or
- platform.system() in ("Windows", "Microsoft")):
- # Trailing slashes are needed to indicate directories on Linux and Windows
- sandbox_whitelist_paths = map(lambda p: os.path.join(p, ""),
- sandbox_whitelist_paths)
-
# Bug 1300355: Disable canvas cache for win7 as it uses
# too much memory and causes OOMs.
if platform.system() in ("Windows", "Microsoft") and \
'6.1' in platform.version():
prefs['reftest.nocache'] = True
if options.marionette:
# options.marionette can specify host:port
port = options.marionette.split(":")[1]
prefs["marionette.port"] = int(port)
# Enable tracing output for detailed failures in case of
# failing connection attempts, and hangs (bug 1397201)
prefs["marionette.log.level"] = "TRACE"
- preference_file = os.path.join(here, 'reftest-preferences.js')
- prefs.update(mozprofile.Preferences.read_prefs(preference_file))
-
+ # Third, set preferences passed in via the command line.
for v in options.extraPrefs:
thispref = v.split('=')
if len(thispref) < 2:
print "Error: syntax error in --setpref=" + v
sys.exit(1)
prefs[thispref[0]] = thispref[1].strip()
- addons = []
- if not self.use_marionette:
- addons.append(options.reftestExtensionPath)
-
- if options.specialPowersExtensionPath is not None:
- if not self.use_marionette:
- addons.append(options.specialPowersExtensionPath)
-
for pref in prefs:
prefs[pref] = mozprofile.Preferences.cast(prefs[pref])
-
- # Install distributed extensions, if application has any.
- distExtDir = os.path.join(options.app[:options.app.rfind(os.sep)],
- "distribution", "extensions")
- if os.path.isdir(distExtDir):
- for f in os.listdir(distExtDir):
- addons.append(os.path.join(distExtDir, f))
-
- # Install custom extensions.
- for f in options.extensionsToInstall:
- addons.append(self.getFullPath(f))
-
- kwargs = {'addons': addons,
- 'preferences': prefs,
- 'locations': locations,
- 'whitelistpaths': sandbox_whitelist_paths}
- if profile_to_clone:
- profile = mozprofile.Profile.clone(profile_to_clone, **kwargs)
- else:
- profile = mozprofile.Profile(**kwargs)
-
- if tests:
- testlist = os.path.join(profile.profile, 'reftests.json')
- with open(testlist, 'w') as fh:
- json.dump(tests, fh)
- profile.set_preferences({'reftest.tests': testlist})
- elif manifests:
- profile.set_preferences({'reftest.manifests': json.dumps(manifests)})
+ profile.set_preferences(prefs)
if os.path.join(here, 'chrome') not in options.extraProfileFiles:
options.extraProfileFiles.append(os.path.join(here, 'chrome'))
self.copyExtraFilesToProfile(options, profile)
return profile
def environment(self, **kwargs):
--- a/testing/profiles/moz.build
+++ b/testing/profiles/moz.build
@@ -3,16 +3,18 @@
# 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/.
profile_files = [
'common/*',
'perf/*',
'profiles.json',
+ 'reftest/*',
'unittest/*',
]
+TEST_HARNESS_FILES.reftest.profile_data += profile_files
TEST_HARNESS_FILES.testing.mochitest.profile_data += profile_files
TEST_HARNESS_FILES['web-platform'].prefs += profile_files
with Files("**"):
BUG_COMPONENT = ("Testing", "General")
--- a/testing/profiles/profiles.json
+++ b/testing/profiles/profiles.json
@@ -1,8 +1,9 @@
{
"mochitest": ["common", "unittest"],
"profileserver": ["common", "unittest"],
"raptor": ["common", "perf", "raptor"],
+ "reftest": ["reftest"],
"talos": ["common", "perf"],
"valgrind": ["common", "unittest"],
"web-platform-tests": ["common", "unittest"]
}
new file mode 100644
--- /dev/null
+++ b/testing/profiles/reftest/extensions/README.txt
@@ -0,0 +1,2 @@
+Dropping extensions here will get them installed in all test harnesses
+that make use of this profile.
rename from layout/tools/reftest/reftest-preferences.js
rename to testing/profiles/reftest/user.js