Bug 1460912 - [reftest] Use base profiles in reftest r=gbrown

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

--HG--
rename : layout/tools/reftest/reftest-preferences.js => testing/profiles/reftest/user.js
extra : rebase_source : 1725627d439998d92545e0d4693fbb76a266945f
This commit is contained in:
Andrew Halberstadt 2018-05-07 16:10:29 -04:00
Родитель 862e0f0951
Коммит 57cafcba8c
6 изменённых файлов: 71 добавлений и 50 удалений

Просмотреть файл

@ -20,7 +20,6 @@ TEST_HARNESS_FILES.reftest += [
'/testing/mochitest/server.js',
'mach_test_package_commands.py',
'output.py',
'reftest-preferences.js',
'reftestcommandline.py',
'remotereftest.py',
'runreftest.py',

Просмотреть файл

@ -282,9 +282,61 @@ class RefTest(object):
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:
@ -306,6 +358,15 @@ class RefTest(object):
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
@ -323,13 +384,6 @@ class RefTest(object):
'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 \
@ -345,9 +399,7 @@ class RefTest(object):
# 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:
@ -355,44 +407,9 @@ class RefTest(object):
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'))

Просмотреть файл

@ -8,9 +8,11 @@ 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

Просмотреть файл

@ -2,6 +2,7 @@
"mochitest": ["common", "unittest"],
"profileserver": ["common", "unittest"],
"raptor": ["common", "perf", "raptor"],
"reftest": ["reftest"],
"talos": ["common", "perf"],
"valgrind": ["common", "unittest"],
"web-platform-tests": ["common", "unittest"]

Просмотреть файл

@ -0,0 +1,2 @@
Dropping extensions here will get them installed in all test harnesses
that make use of this profile.