From 997ce091cb3e22b1e0fd83383485a8d6f3b2c84f Mon Sep 17 00:00:00 2001 From: Jonathan Griffin Date: Wed, 14 Oct 2009 10:55:25 -0700 Subject: [PATCH] Bug 519574. Add --setpref to runtests.py, to add custom prefs to mochitest runs. r=mielczarek --HG-- extra : rebase_source : db4f83d61b30b70fe5e3f49b25367f223a1ea5e3 --- build/automation.py.in | 10 +++++++++- testing/mochitest/runtests.py.in | 8 +++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/build/automation.py.in b/build/automation.py.in index 4cd5f6dfb6a0..067e824eb8b5 100644 --- a/build/automation.py.in +++ b/build/automation.py.in @@ -223,7 +223,7 @@ def readLocations(locationsPath = "server-locations.txt"): return locations -def initializeProfile(profileDir): +def initializeProfile(profileDir, extraPrefs = []): "Sets up the standard testing profile." # Start with a clean slate. @@ -333,6 +333,14 @@ user_pref("camino.use_system_proxy_settings", false); // Camino-only, harmless t """ % {"pacURL": pacURL} prefs.append(part) + for v in extraPrefs: + thispref = v.split("=") + if len(thispref) < 2: + print "Error: syntax error in --extra-pref=" + v + sys.exit(1) + part = 'user_pref("%s", %s);\n' % (thispref[0], thispref[1]) + prefs.append(part) + # write the preferences prefsFile = open(profileDir + "/" + "user.js", "a") prefsFile.write("".join(prefs)) diff --git a/testing/mochitest/runtests.py.in b/testing/mochitest/runtests.py.in index 725f3f4376ab..cbe2383fec71 100644 --- a/testing/mochitest/runtests.py.in +++ b/testing/mochitest/runtests.py.in @@ -214,6 +214,12 @@ class MochitestOptions(optparse.OptionParser): "environment") defaults["environment"] = [] + self.add_option("--setpref", + action = "append", type = "string", + dest = "extraPrefs", metavar = "PREF=VALUE", + help = "defines an extra user preference") + defaults["extraPrefs"] = [] + self.add_option("--browser-arg", action = "append", type = "string", dest = "browserArgs", metavar = "ARG", @@ -426,7 +432,7 @@ Are you executing $objdir/_tests/testing/mochitest/runtests.py?""" sys.exit(1) browserEnv[v[:ix]] = v[ix + 1:] - automation.initializeProfile(PROFILE_DIRECTORY) + automation.initializeProfile(PROFILE_DIRECTORY, options.extraPrefs) manifest = addChromeToProfile(options) copyExtraFilesToProfile(options) server = MochitestServer(options)