From 9d4e70e54d3cfb962313d6bc1e21ad0a9cc4945b Mon Sep 17 00:00:00 2001 From: Clint Talbert Date: Wed, 25 Nov 2009 18:00:31 -0800 Subject: [PATCH] Causing oranges -- Backed out changeset b3c18f150531 --- build/automation.py.in | 35 +++---- testing/mochitest/runtests.py.in | 160 +++++++++++++------------------ testing/mochitest/server.js | 9 +- 3 files changed, 81 insertions(+), 123 deletions(-) diff --git a/build/automation.py.in b/build/automation.py.in index f3294caa31c..d96f1aff733 100644 --- a/build/automation.py.in +++ b/build/automation.py.in @@ -102,8 +102,6 @@ UNIXISH = not IS_WIN32 and not IS_MAC #expand IS_DEBUG_BUILD = __IS_DEBUG_BUILD__ #expand CRASHREPORTER = __CRASHREPORTER__ == 1 -DEFAULT_WEB_SERVER = "localhost:8888" - ########### # LOGGING # ########### @@ -174,7 +172,7 @@ class Location: 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 server-locations.txt. @@ -211,22 +209,18 @@ def readLocations(locationsPath = "server-locations.txt", remoteServer = DEFAULT if not match: raise SyntaxError(lineno) - host = match.group("host") - port = match.group("port") options = match.group("options") if options: options = options.split(",") if "primary" in options: if seenPrimary: raise SyntaxError(lineno, "multiple primary locations") - - #we can have only 1 primary, make it the remoteServer - host, port = remoteServer.split(':') seenPrimary = True else: 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: raise SyntaxError(lineno + 1, "missing primary location") @@ -234,14 +228,13 @@ def readLocations(locationsPath = "server-locations.txt", remoteServer = DEFAULT return locations -def initializeProfile(profileDir, extraPrefs = [], webServer = DEFAULT_WEB_SERVER): +def initializeProfile(profileDir, extraPrefs = []): "Sets up the standard testing profile." # Start with a clean slate. shutil.rmtree(profileDir, True) os.mkdir(profileDir) - remoteIP = webServer.split(':')[0] prefs = [] 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("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("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 user_pref("urlclassifier.updateinterval", 172800); // 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.keyURL", "http://example.com/safebrowsing-dummy/newkey"); -user_pref("browser.safebrowsing.provider.0.lookupURL", "http://example.com/safebrowsing-dummy/lookup"); -user_pref("browser.safebrowsing.provider.0.updateURL", "http://example.com/safebrowsing-dummy/update"); +user_pref("browser.safebrowsing.provider.0.gethashURL", "http://localhost:8888/safebrowsing-dummy/gethash"); +user_pref("browser.safebrowsing.provider.0.keyURL", "http://localhost:8888/safebrowsing-dummy/newkey"); +user_pref("browser.safebrowsing.provider.0.lookupURL", "http://localhost:8888/safebrowsing-dummy/lookup"); +user_pref("browser.safebrowsing.provider.0.updateURL", "http://localhost:8888/safebrowsing-dummy/update"); """ prefs.append(part) - locations = readLocations(remoteServer=webServer) + locations = readLocations() # Grant God-power to all the privileged servers on which tests run. 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, 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+.]*)' + '://' + '(?:[^/@]*@)?' + @@ -331,11 +324,11 @@ function FindProxyForURL(url, host) if (origins.indexOf(origin) < 0) return 'DIRECT'; if (isHttp) - return 'PROXY %(remote)s:8888'; + return 'PROXY 127.0.0.1:8888'; if (isHttps) - return 'PROXY %(remote)s:4443'; + return 'PROXY 127.0.0.1:4443'; return 'DIRECT'; -}""" % { "origins": origins, "remote":remoteIP } +}""" % { "origins": origins } pacURL = "".join(pacURL.splitlines()) part = """ diff --git a/testing/mochitest/runtests.py.in b/testing/mochitest/runtests.py.in index a597442f29d..87f3a9fc58e 100644 --- a/testing/mochitest/runtests.py.in +++ b/testing/mochitest/runtests.py.in @@ -54,13 +54,16 @@ import urllib2 import commands import automation from automationutils import * -import tempfile # Path to the test script on the server +TEST_SERVER_HOST = "localhost:8888" TEST_PATH = "/tests/" CHROME_PATH = "/redirect.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 #ifdef MOZ_SUITE 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]))) os.chdir(SCRIPT_DIRECTORY) +PROFILE_DIRECTORY = os.path.abspath("./mochitesttestingprofile") + +LEAK_REPORT_FILE = os.path.join(PROFILE_DIRECTORY, "runtests_leaks.log") ####################### # COMMANDLINE OPTIONS # @@ -222,20 +228,6 @@ class MochitestOptions(optparse.OptionParser): help = "copy specified files/dirs to testing profile") 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 self.set_defaults(**defaults) @@ -261,8 +253,6 @@ class MochitestServer: self._closeWhenDone = options.closeWhenDone self._utilityPath = options.utilityPath self._xrePath = options.xrePath - self._shutdownPath = "http://" + options.webServer + "/server/shutdown" - self._profilePath = options.profilePath def start(self): "Run the Mochitest server, returning the process ID of the server." @@ -275,7 +265,6 @@ class MochitestServer: args = ["-g", self._xrePath, "-v", "170", "-f", "./" + "httpd.js", - "-e", "const _PROFILE_PATH = '" + self._profilePath + "'", "-f", "./" + "server.js"] xpcshell = os.path.join(self._utilityPath, @@ -291,7 +280,7 @@ class MochitestServer: def ensureReady(self, timeout): assert timeout >= 0 - aliveFile = os.path.join(self._profilePath, "server_alive.txt") + aliveFile = os.path.join(PROFILE_DIRECTORY, "server_alive.txt") i = 0 while i < timeout: if os.path.exists(aliveFile): @@ -305,7 +294,7 @@ class MochitestServer: def stop(self): try: - c = urllib2.urlopen(self._shutdownPath) + c = urllib2.urlopen(SERVER_SHUTDOWN_URL) c.read() c.close() self._process.wait() @@ -343,8 +332,6 @@ def main(): # allow relative paths options.xrePath = getFullPath(options.xrePath) - options.profilePath = getFullPath(options.profilePath) - options.app = getFullPath(options.app) if not os.path.exists(options.app): msg = """\ @@ -358,13 +345,6 @@ Are you executing $objdir/_tests/testing/mochitest/runtests.py?""" if 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, options.debuggerInteractive); @@ -382,21 +362,17 @@ Are you executing $objdir/_tests/testing/mochitest/runtests.py?""" sys.exit(1) browserEnv[v[:ix]] = v[ix + 1:] - automation.initializeProfile(options.profilePath, options.extraPrefs, options.webServer) + automation.initializeProfile(PROFILE_DIRECTORY, options.extraPrefs) manifest = addChromeToProfile(options) copyExtraFilesToProfile(options) - if (options.setupOnly): - return + server = MochitestServer(options) + server.start() - if (not options.remoteWebServer): - server = MochitestServer(options) - server.start() - - # If we're lucky, the server has fully started by now, and all paths are - # 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) + # If we're lucky, the server has fully started by now, and all paths are + # 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: # @@ -412,14 +388,14 @@ Are you executing $objdir/_tests/testing/mochitest/runtests.py?""" # file logs, if activated. # - testURL = "http://" + options.webServer + "/tests/" + options.testPath + testURL = TESTS_URL + options.testPath urlOpts = [] if options.chrome: - testURL = "http://" + options.webServer + CHROME_PATH + testURL = CHROMETESTS_URL if options.testPath: urlOpts.append("testPath=" + encodeURIComponent(options.testPath)) elif options.a11y: - testURL = "http://" + options.webServer + A11Y_PATH + testURL = A11YTESTS_URL if options.testPath: urlOpts.append("testPath=" + encodeURIComponent(options.testPath)) elif options.browserChrome: @@ -452,61 +428,55 @@ Are you executing $objdir/_tests/testing/mochitest/runtests.py?""" if len(urlOpts) > 0: 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: browserEnv["XPCOM_DEBUG_BREAK"] = "stack-and-abort" - try: - # run once with -silent to let the extension manager do its thing - # and then exit the app - automation.log.info("INFO | runtests.py | Performing extension manager registration: start.\n") - # Don't care about this |status|: |runApp()| reporting it should be enough. - status = automation.runApp(None, browserEnv, options.app, - options.profilePath, ["-silent"], - utilityPath = options.utilityPath, - xrePath = options.xrePath, - symbolsPath=options.symbolsPath) - # We don't care to call |processLeakLog()| for this step. - automation.log.info("\nINFO | runtests.py | Performing extension manager registration: end.") + # run once with -silent to let the extension manager do its thing + # and then exit the app + automation.log.info("INFO | runtests.py | Performing extension manager registration: start.\n") + # Don't care about this |status|: |runApp()| reporting it should be enough. + status = automation.runApp(None, browserEnv, options.app, + PROFILE_DIRECTORY, ["-silent"], + utilityPath = options.utilityPath, + xrePath = options.xrePath, + symbolsPath=options.symbolsPath) + # We don't care to call |processLeakLog()| for this step. + 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. - # The file is not there if leak logging was not enabled in the application build. - if os.path.exists(leak_report_file): - os.remove(leak_report_file) + # 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. + if os.path.exists(LEAK_REPORT_FILE): + os.remove(LEAK_REPORT_FILE) - # then again to actually run mochitest - if options.timeout: - timeout = options.timeout + 30 - elif options.autorun: - timeout = None - else: - timeout = 330.0 # default JS harness timeout is 300 seconds - automation.log.info("INFO | runtests.py | Running tests: start.\n") - status = automation.runApp(testURL, browserEnv, options.app, - options.profilePath, options.browserArgs, - runSSLTunnel = True, - utilityPath = options.utilityPath, - xrePath = options.xrePath, - certPath=options.certPath, - debuggerInfo=debuggerInfo, - symbolsPath=options.symbolsPath, - timeout = timeout) + # then again to actually run mochitest + if options.timeout: + timeout = options.timeout + 30 + elif options.autorun: + timeout = None + else: + timeout = 330.0 # default JS harness timeout is 300 seconds + automation.log.info("INFO | runtests.py | Running tests: start.\n") + status = automation.runApp(testURL, browserEnv, options.app, + PROFILE_DIRECTORY, options.browserArgs, + runSSLTunnel = True, + utilityPath = options.utilityPath, + xrePath = options.xrePath, + certPath=options.certPath, + debuggerInfo=debuggerInfo, + symbolsPath=options.symbolsPath, + timeout = timeout) - if (not options.remoteWebServer): - # 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. - server.stop() + # 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. + server.stop() - processLeakLog(leak_report_file, options.leakThreshold) - automation.log.info("\nINFO | runtests.py | Running tests: end.") + processLeakLog(LEAK_REPORT_FILE, options.leakThreshold) + automation.log.info("\nINFO | runtests.py | Running tests: end.") - finally: - # delete the profile and manifest - if (options.profilePath): - shutil.rmtree(options.profilePath) - os.remove(manifest) + # delete the profile and manifest + os.remove(manifest) # hanging due to non-halting threads is no fun; assume we hit the errors we # were going to hit already and exit. @@ -538,7 +508,7 @@ def makeTestConfig(options): "logPath": logFile, "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.close() @@ -546,7 +516,7 @@ def makeTestConfig(options): def addChromeToProfile(options): "Adds MochiKit chrome tests to the profile." - chromedir = os.path.join(options.profilePath, "chrome") + chromedir = os.path.join(PROFILE_DIRECTORY, "chrome") os.mkdir(chromedir) chrome = [] @@ -566,7 +536,7 @@ toolbar#nav-bar { # 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.close() @@ -593,7 +563,7 @@ def copyExtraFilesToProfile(options): "Copy extra files or dirs specified on the command line to the testing profile." for f in options.extraProfileFiles: 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): shutil.copytree(abspath, dest) else: diff --git a/testing/mochitest/server.js b/testing/mochitest/server.js index c7b6baee784..8b555e2c7e2 100644 --- a/testing/mochitest/server.js +++ b/testing/mochitest/server.js @@ -157,13 +157,8 @@ function runServer() .createInstance(Ci.nsIFileOutputStream); var serverAlive = Cc["@mozilla.org/file/local;1"] .createInstance(Ci.nsILocalFile); - - if (typeof(_PROFILE_PATH) == "undefined") { - serverAlive.initWithFile(serverBasePath); - serverAlive.append("mochitesttestingprofile"); - } else { - serverAlive.initWithPath(_PROFILE_PATH); - } + serverAlive.initWithFile(serverBasePath); + serverAlive.append("mochitesttestingprofile"); // If we're running outside of the test harness, there might // not be a test profile directory present