Causing oranges -- Backed out changeset b3c18f150531

This commit is contained in:
Clint Talbert 2009-11-25 18:00:31 -08:00
Родитель 70fe8530fc
Коммит 3457d8a6b5
3 изменённых файлов: 81 добавлений и 123 удалений

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

@ -102,8 +102,6 @@ UNIXISH = not IS_WIN32 and not IS_MAC
#expand IS_DEBUG_BUILD = __IS_DEBUG_BUILD__ #expand IS_DEBUG_BUILD = __IS_DEBUG_BUILD__
#expand CRASHREPORTER = __CRASHREPORTER__ == 1 #expand CRASHREPORTER = __CRASHREPORTER__ == 1
DEFAULT_WEB_SERVER = "localhost:8888"
########### ###########
# LOGGING # # LOGGING #
########### ###########
@ -174,7 +172,7 @@ class Location:
self.options = options self.options = options
def readLocations(locationsPath = "server-locations.txt", remoteServer = DEFAULT_WEB_SERVER): def readLocations(locationsPath = "server-locations.txt"):
""" """
Reads the locations at which the Mochitest HTTP server is available from Reads the locations at which the Mochitest HTTP server is available from
server-locations.txt. server-locations.txt.
@ -211,22 +209,18 @@ def readLocations(locationsPath = "server-locations.txt", remoteServer = DEFAULT
if not match: if not match:
raise SyntaxError(lineno) raise SyntaxError(lineno)
host = match.group("host")
port = match.group("port")
options = match.group("options") options = match.group("options")
if options: if options:
options = options.split(",") options = options.split(",")
if "primary" in options: if "primary" in options:
if seenPrimary: if seenPrimary:
raise SyntaxError(lineno, "multiple primary locations") raise SyntaxError(lineno, "multiple primary locations")
#we can have only 1 primary, make it the remoteServer
host, port = remoteServer.split(':')
seenPrimary = True seenPrimary = True
else: else:
options = [] options = []
locations.append(Location(match.group("scheme"), host, port, options)) locations.append(Location(match.group("scheme"), match.group("host"),
match.group("port"), options))
if not seenPrimary: if not seenPrimary:
raise SyntaxError(lineno + 1, "missing primary location") raise SyntaxError(lineno + 1, "missing primary location")
@ -234,14 +228,13 @@ def readLocations(locationsPath = "server-locations.txt", remoteServer = DEFAULT
return locations return locations
def initializeProfile(profileDir, extraPrefs = [], webServer = DEFAULT_WEB_SERVER): def initializeProfile(profileDir, extraPrefs = []):
"Sets up the standard testing profile." "Sets up the standard testing profile."
# Start with a clean slate. # Start with a clean slate.
shutil.rmtree(profileDir, True) shutil.rmtree(profileDir, True)
os.mkdir(profileDir) os.mkdir(profileDir)
remoteIP = webServer.split(':')[0]
prefs = [] prefs = []
part = """\ part = """\
@ -270,7 +263,7 @@ user_pref("svg.smil.enabled", true); // Needed for SMIL mochitests until bug 482
user_pref("media.cache_size", 100); user_pref("media.cache_size", 100);
user_pref("security.warn_viewing_mixed", false); user_pref("security.warn_viewing_mixed", false);
user_pref("geo.wifi.uri", "http://example.com/tests/dom/tests/mochitest/geolocation/network_geolocation.sjs"); user_pref("geo.wifi.uri", "http://localhost:8888/tests/dom/tests/mochitest/geolocation/network_geolocation.sjs");
user_pref("geo.wifi.testing", true); user_pref("geo.wifi.testing", true);
user_pref("camino.warn_when_closing", false); // Camino-only, harmless to others user_pref("camino.warn_when_closing", false); // Camino-only, harmless to others
@ -278,15 +271,15 @@ user_pref("camino.warn_when_closing", false); // Camino-only, harmless to others
// Make url-classifier updates so rare that they won't affect tests // Make url-classifier updates so rare that they won't affect tests
user_pref("urlclassifier.updateinterval", 172800); user_pref("urlclassifier.updateinterval", 172800);
// Point the url-classifier to the local testing server for fast failures // Point the url-classifier to the local testing server for fast failures
user_pref("browser.safebrowsing.provider.0.gethashURL", "http://example.com/safebrowsing-dummy/gethash"); user_pref("browser.safebrowsing.provider.0.gethashURL", "http://localhost:8888/safebrowsing-dummy/gethash");
user_pref("browser.safebrowsing.provider.0.keyURL", "http://example.com/safebrowsing-dummy/newkey"); user_pref("browser.safebrowsing.provider.0.keyURL", "http://localhost:8888/safebrowsing-dummy/newkey");
user_pref("browser.safebrowsing.provider.0.lookupURL", "http://example.com/safebrowsing-dummy/lookup"); user_pref("browser.safebrowsing.provider.0.lookupURL", "http://localhost:8888/safebrowsing-dummy/lookup");
user_pref("browser.safebrowsing.provider.0.updateURL", "http://example.com/safebrowsing-dummy/update"); user_pref("browser.safebrowsing.provider.0.updateURL", "http://localhost:8888/safebrowsing-dummy/update");
""" """
prefs.append(part) prefs.append(part)
locations = readLocations(remoteServer=webServer) locations = readLocations()
# Grant God-power to all the privileged servers on which tests run. # Grant God-power to all the privileged servers on which tests run.
privileged = filter(lambda loc: "privileged" in loc.options, locations) privileged = filter(lambda loc: "privileged" in loc.options, locations)
@ -310,7 +303,7 @@ user_pref("capability.principal.codebase.p%(i)d.subjectName", "");
pacURL = """data:text/plain, pacURL = """data:text/plain,
function FindProxyForURL(url, host) function FindProxyForURL(url, host)
{ {
var origins = ['http://%(remote)s:8888', %(origins)s]; var origins = [%(origins)s];
var regex = new RegExp('^([a-z][-a-z0-9+.]*)' + var regex = new RegExp('^([a-z][-a-z0-9+.]*)' +
'://' + '://' +
'(?:[^/@]*@)?' + '(?:[^/@]*@)?' +
@ -331,11 +324,11 @@ function FindProxyForURL(url, host)
if (origins.indexOf(origin) < 0) if (origins.indexOf(origin) < 0)
return 'DIRECT'; return 'DIRECT';
if (isHttp) if (isHttp)
return 'PROXY %(remote)s:8888'; return 'PROXY 127.0.0.1:8888';
if (isHttps) if (isHttps)
return 'PROXY %(remote)s:4443'; return 'PROXY 127.0.0.1:4443';
return 'DIRECT'; return 'DIRECT';
}""" % { "origins": origins, "remote":remoteIP } }""" % { "origins": origins }
pacURL = "".join(pacURL.splitlines()) pacURL = "".join(pacURL.splitlines())
part = """ part = """

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

@ -54,13 +54,16 @@ import urllib2
import commands import commands
import automation import automation
from automationutils import * from automationutils import *
import tempfile
# Path to the test script on the server # Path to the test script on the server
TEST_SERVER_HOST = "localhost:8888"
TEST_PATH = "/tests/" TEST_PATH = "/tests/"
CHROME_PATH = "/redirect.html"; CHROME_PATH = "/redirect.html";
A11Y_PATH = "/redirect-a11y.html" A11Y_PATH = "/redirect-a11y.html"
TESTS_URL = "http://" + TEST_SERVER_HOST + TEST_PATH
CHROMETESTS_URL = "http://" + TEST_SERVER_HOST + CHROME_PATH
A11YTESTS_URL = "http://" + TEST_SERVER_HOST + A11Y_PATH
SERVER_SHUTDOWN_URL = "http://" + TEST_SERVER_HOST + "/server/shutdown"
# main browser chrome URL, same as browser.chromeURL pref # main browser chrome URL, same as browser.chromeURL pref
#ifdef MOZ_SUITE #ifdef MOZ_SUITE
BROWSER_CHROME_URL = "chrome://navigator/content/navigator.xul" BROWSER_CHROME_URL = "chrome://navigator/content/navigator.xul"
@ -80,6 +83,9 @@ oldcwd = os.getcwd()
SCRIPT_DIRECTORY = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0]))) SCRIPT_DIRECTORY = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0])))
os.chdir(SCRIPT_DIRECTORY) os.chdir(SCRIPT_DIRECTORY)
PROFILE_DIRECTORY = os.path.abspath("./mochitesttestingprofile")
LEAK_REPORT_FILE = os.path.join(PROFILE_DIRECTORY, "runtests_leaks.log")
####################### #######################
# COMMANDLINE OPTIONS # # COMMANDLINE OPTIONS #
@ -222,20 +228,6 @@ class MochitestOptions(optparse.OptionParser):
help = "copy specified files/dirs to testing profile") help = "copy specified files/dirs to testing profile")
defaults["extraProfileFiles"] = [] defaults["extraProfileFiles"] = []
self.add_option("--remote-webserver", action = "store",
type = "string", dest = "remoteWebServer",
help = "ip address where the remote web server is hosted at")
defaults["remoteWebServer"] = None
self.add_option("--profile-path", action = "store",
type = "string", dest = "profilePath",
help = "directory where the profile will be stored")
defaults["profilePath"] = tempfile.mkdtemp()
self.add_option("--setup-only", action = "store_true",
dest = "setupOnly", help = "only setup the profile, do not run tests")
defaults["setupOnly"] = False
# -h, --help are automatically handled by OptionParser # -h, --help are automatically handled by OptionParser
self.set_defaults(**defaults) self.set_defaults(**defaults)
@ -261,8 +253,6 @@ class MochitestServer:
self._closeWhenDone = options.closeWhenDone self._closeWhenDone = options.closeWhenDone
self._utilityPath = options.utilityPath self._utilityPath = options.utilityPath
self._xrePath = options.xrePath self._xrePath = options.xrePath
self._shutdownPath = "http://" + options.webServer + "/server/shutdown"
self._profilePath = options.profilePath
def start(self): def start(self):
"Run the Mochitest server, returning the process ID of the server." "Run the Mochitest server, returning the process ID of the server."
@ -275,7 +265,6 @@ class MochitestServer:
args = ["-g", self._xrePath, args = ["-g", self._xrePath,
"-v", "170", "-v", "170",
"-f", "./" + "httpd.js", "-f", "./" + "httpd.js",
"-e", "const _PROFILE_PATH = '" + self._profilePath + "'",
"-f", "./" + "server.js"] "-f", "./" + "server.js"]
xpcshell = os.path.join(self._utilityPath, xpcshell = os.path.join(self._utilityPath,
@ -291,7 +280,7 @@ class MochitestServer:
def ensureReady(self, timeout): def ensureReady(self, timeout):
assert timeout >= 0 assert timeout >= 0
aliveFile = os.path.join(self._profilePath, "server_alive.txt") aliveFile = os.path.join(PROFILE_DIRECTORY, "server_alive.txt")
i = 0 i = 0
while i < timeout: while i < timeout:
if os.path.exists(aliveFile): if os.path.exists(aliveFile):
@ -305,7 +294,7 @@ class MochitestServer:
def stop(self): def stop(self):
try: try:
c = urllib2.urlopen(self._shutdownPath) c = urllib2.urlopen(SERVER_SHUTDOWN_URL)
c.read() c.read()
c.close() c.close()
self._process.wait() self._process.wait()
@ -343,8 +332,6 @@ def main():
# allow relative paths # allow relative paths
options.xrePath = getFullPath(options.xrePath) options.xrePath = getFullPath(options.xrePath)
options.profilePath = getFullPath(options.profilePath)
options.app = getFullPath(options.app) options.app = getFullPath(options.app)
if not os.path.exists(options.app): if not os.path.exists(options.app):
msg = """\ msg = """\
@ -358,13 +345,6 @@ Are you executing $objdir/_tests/testing/mochitest/runtests.py?"""
if options.symbolsPath: if options.symbolsPath:
options.symbolsPath = getFullPath(options.symbolsPath) options.symbolsPath = getFullPath(options.symbolsPath)
if (options.remoteWebServer):
if (len(options.remoteWebServer.split(':')) == 1):
options.remoteWebServer += ":8888"
options.webServer = options.remoteWebServer
else:
options.webServer = "localhost:8888"
debuggerInfo = getDebuggerInfo(oldcwd, options.debugger, options.debuggerArgs, debuggerInfo = getDebuggerInfo(oldcwd, options.debugger, options.debuggerArgs,
options.debuggerInteractive); options.debuggerInteractive);
@ -382,21 +362,17 @@ Are you executing $objdir/_tests/testing/mochitest/runtests.py?"""
sys.exit(1) sys.exit(1)
browserEnv[v[:ix]] = v[ix + 1:] browserEnv[v[:ix]] = v[ix + 1:]
automation.initializeProfile(options.profilePath, options.extraPrefs, options.webServer) automation.initializeProfile(PROFILE_DIRECTORY, options.extraPrefs)
manifest = addChromeToProfile(options) manifest = addChromeToProfile(options)
copyExtraFilesToProfile(options) copyExtraFilesToProfile(options)
if (options.setupOnly): server = MochitestServer(options)
return server.start()
if (not options.remoteWebServer): # If we're lucky, the server has fully started by now, and all paths are
server = MochitestServer(options) # ready, etc. However, xpcshell cold start times suck, at least for debug
server.start() # builds. We'll try to connect to the server for awhile, and if we fail,
# we'll try to kill the server and exit with an error.
# If we're lucky, the server has fully started by now, and all paths are server.ensureReady(SERVER_STARTUP_TIMEOUT)
# ready, etc. However, xpcshell cold start times suck, at least for debug
# builds. We'll try to connect to the server for awhile, and if we fail,
# we'll try to kill the server and exit with an error.
server.ensureReady(SERVER_STARTUP_TIMEOUT)
# URL parameters to test URL: # URL parameters to test URL:
# #
@ -412,14 +388,14 @@ Are you executing $objdir/_tests/testing/mochitest/runtests.py?"""
# file logs, if activated. # file logs, if activated.
# <http://mochikit.com/doc/html/MochiKit/Logging.html> # <http://mochikit.com/doc/html/MochiKit/Logging.html>
testURL = "http://" + options.webServer + "/tests/" + options.testPath testURL = TESTS_URL + options.testPath
urlOpts = [] urlOpts = []
if options.chrome: if options.chrome:
testURL = "http://" + options.webServer + CHROME_PATH testURL = CHROMETESTS_URL
if options.testPath: if options.testPath:
urlOpts.append("testPath=" + encodeURIComponent(options.testPath)) urlOpts.append("testPath=" + encodeURIComponent(options.testPath))
elif options.a11y: elif options.a11y:
testURL = "http://" + options.webServer + A11Y_PATH testURL = A11YTESTS_URL
if options.testPath: if options.testPath:
urlOpts.append("testPath=" + encodeURIComponent(options.testPath)) urlOpts.append("testPath=" + encodeURIComponent(options.testPath))
elif options.browserChrome: elif options.browserChrome:
@ -452,61 +428,55 @@ Are you executing $objdir/_tests/testing/mochitest/runtests.py?"""
if len(urlOpts) > 0: if len(urlOpts) > 0:
testURL += "?" + "&".join(urlOpts) testURL += "?" + "&".join(urlOpts)
leak_report_file = os.path.join(options.profilePath, "runtests_leaks.log") browserEnv["XPCOM_MEM_BLOAT_LOG"] = LEAK_REPORT_FILE
browserEnv["XPCOM_MEM_BLOAT_LOG"] = leak_report_file
if options.fatalAssertions: if options.fatalAssertions:
browserEnv["XPCOM_DEBUG_BREAK"] = "stack-and-abort" browserEnv["XPCOM_DEBUG_BREAK"] = "stack-and-abort"
try: # run once with -silent to let the extension manager do its thing
# run once with -silent to let the extension manager do its thing # and then exit the app
# and then exit the app automation.log.info("INFO | runtests.py | Performing extension manager registration: start.\n")
automation.log.info("INFO | runtests.py | Performing extension manager registration: start.\n") # Don't care about this |status|: |runApp()| reporting it should be enough.
# Don't care about this |status|: |runApp()| reporting it should be enough. status = automation.runApp(None, browserEnv, options.app,
status = automation.runApp(None, browserEnv, options.app, PROFILE_DIRECTORY, ["-silent"],
options.profilePath, ["-silent"], utilityPath = options.utilityPath,
utilityPath = options.utilityPath, xrePath = options.xrePath,
xrePath = options.xrePath, symbolsPath=options.symbolsPath)
symbolsPath=options.symbolsPath) # We don't care to call |processLeakLog()| for this step.
# We don't care to call |processLeakLog()| for this step. automation.log.info("\nINFO | runtests.py | Performing extension manager registration: end.")
automation.log.info("\nINFO | runtests.py | Performing extension manager registration: end.")
# Remove the leak detection file so it can't "leak" to the tests run. # Remove the leak detection file so it can't "leak" to the tests run.
# The file is not there if leak logging was not enabled in the application build. # The file is not there if leak logging was not enabled in the application build.
if os.path.exists(leak_report_file): if os.path.exists(LEAK_REPORT_FILE):
os.remove(leak_report_file) os.remove(LEAK_REPORT_FILE)
# then again to actually run mochitest # then again to actually run mochitest
if options.timeout: if options.timeout:
timeout = options.timeout + 30 timeout = options.timeout + 30
elif options.autorun: elif options.autorun:
timeout = None timeout = None
else: else:
timeout = 330.0 # default JS harness timeout is 300 seconds timeout = 330.0 # default JS harness timeout is 300 seconds
automation.log.info("INFO | runtests.py | Running tests: start.\n") automation.log.info("INFO | runtests.py | Running tests: start.\n")
status = automation.runApp(testURL, browserEnv, options.app, status = automation.runApp(testURL, browserEnv, options.app,
options.profilePath, options.browserArgs, PROFILE_DIRECTORY, options.browserArgs,
runSSLTunnel = True, runSSLTunnel = True,
utilityPath = options.utilityPath, utilityPath = options.utilityPath,
xrePath = options.xrePath, xrePath = options.xrePath,
certPath=options.certPath, certPath=options.certPath,
debuggerInfo=debuggerInfo, debuggerInfo=debuggerInfo,
symbolsPath=options.symbolsPath, symbolsPath=options.symbolsPath,
timeout = timeout) timeout = timeout)
if (not options.remoteWebServer): # Server's no longer needed, and perhaps more importantly, anything it might
# Server's no longer needed, and perhaps more importantly, anything it might # spew to console shouldn't disrupt the leak information table we print next.
# spew to console shouldn't disrupt the leak information table we print next. server.stop()
server.stop()
processLeakLog(leak_report_file, options.leakThreshold) processLeakLog(LEAK_REPORT_FILE, options.leakThreshold)
automation.log.info("\nINFO | runtests.py | Running tests: end.") automation.log.info("\nINFO | runtests.py | Running tests: end.")
finally: # delete the profile and manifest
# delete the profile and manifest os.remove(manifest)
if (options.profilePath):
shutil.rmtree(options.profilePath)
os.remove(manifest)
# hanging due to non-halting threads is no fun; assume we hit the errors we # hanging due to non-halting threads is no fun; assume we hit the errors we
# were going to hit already and exit. # were going to hit already and exit.
@ -538,7 +508,7 @@ def makeTestConfig(options):
"logPath": logFile, "logPath": logFile,
"testPath": testPath} "testPath": testPath}
config = open(os.path.join(options.profilePath, "testConfig.js"), "w") config = open(os.path.join(PROFILE_DIRECTORY, "testConfig.js"), "w")
config.write(content) config.write(content)
config.close() config.close()
@ -546,7 +516,7 @@ def makeTestConfig(options):
def addChromeToProfile(options): def addChromeToProfile(options):
"Adds MochiKit chrome tests to the profile." "Adds MochiKit chrome tests to the profile."
chromedir = os.path.join(options.profilePath, "chrome") chromedir = os.path.join(PROFILE_DIRECTORY, "chrome")
os.mkdir(chromedir) os.mkdir(chromedir)
chrome = [] chrome = []
@ -566,7 +536,7 @@ toolbar#nav-bar {
# write userChrome.css # write userChrome.css
chromeFile = open(os.path.join(options.profilePath, "userChrome.css"), "a") chromeFile = open(os.path.join(PROFILE_DIRECTORY, "userChrome.css"), "a")
chromeFile.write("".join(chrome)) chromeFile.write("".join(chrome))
chromeFile.close() chromeFile.close()
@ -593,7 +563,7 @@ def copyExtraFilesToProfile(options):
"Copy extra files or dirs specified on the command line to the testing profile." "Copy extra files or dirs specified on the command line to the testing profile."
for f in options.extraProfileFiles: for f in options.extraProfileFiles:
abspath = getFullPath(f) abspath = getFullPath(f)
dest = os.path.join(options.profilePath, os.path.basename(abspath)) dest = os.path.join(PROFILE_DIRECTORY, os.path.basename(abspath))
if os.path.isdir(abspath): if os.path.isdir(abspath):
shutil.copytree(abspath, dest) shutil.copytree(abspath, dest)
else: else:

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

@ -157,13 +157,8 @@ function runServer()
.createInstance(Ci.nsIFileOutputStream); .createInstance(Ci.nsIFileOutputStream);
var serverAlive = Cc["@mozilla.org/file/local;1"] var serverAlive = Cc["@mozilla.org/file/local;1"]
.createInstance(Ci.nsILocalFile); .createInstance(Ci.nsILocalFile);
serverAlive.initWithFile(serverBasePath);
if (typeof(_PROFILE_PATH) == "undefined") { serverAlive.append("mochitesttestingprofile");
serverAlive.initWithFile(serverBasePath);
serverAlive.append("mochitesttestingprofile");
} else {
serverAlive.initWithPath(_PROFILE_PATH);
}
// If we're running outside of the test harness, there might // If we're running outside of the test harness, there might
// not be a test profile directory present // not be a test profile directory present