def switchToLocalPaths(self, options): """ Set local paths in the options, return a function that will restore remote values """ remoteXrePath = options.xrePath remoteProfilePath = options.profilePath remoteUtilityPath = options.utilityPath paths = [ options.xrePath, ] if build_obj: paths.append(os.path.join(build_obj.topobjdir, "dist", "bin")) options.xrePath = self.findPath(paths) if options.xrePath is None: self.log.error( "unable to find xulrunner path for %s, please specify with --xre-path" % os.name) sys.exit(1) xpcshell = "xpcshell" if os.name == "nt": xpcshell += ".exe" if options.utilityPath: paths = [options.utilityPath, options.xrePath] else: paths = [options.xrePath] options.utilityPath = self.findPath(paths, xpcshell) if options.utilityPath is None: self.log.error( "unable to find utility path for %s, please specify with --utility-path" % os.name) sys.exit(1) xpcshell_path = os.path.join(options.utilityPath, xpcshell) if RemoteAutomation.elf_arm(xpcshell_path): self.log.error("xpcshell at %s is an ARM binary; please use " "the --utility-path argument to specify the path " "to a desktop version." % xpcshell_path) sys.exit(1) if self.localProfile: options.profilePath = self.localProfile else: options.profilePath = None def fixup(): options.xrePath = remoteXrePath options.utilityPath = remoteUtilityPath options.profilePath = remoteProfilePath return fixup
def start(self): "Run the Refest server, returning the process ID of the server." env = dict(os.environ) env["XPCOM_DEBUG_BREAK"] = "warn" bin_suffix = "" if sys.platform in ("win32", "msys", "cygwin"): env["PATH"] = env["PATH"] + ";" + self.xrePath bin_suffix = ".exe" else: if "LD_LIBRARY_PATH" not in env or env["LD_LIBRARY_PATH"] is None: env["LD_LIBRARY_PATH"] = self.xrePath else: env["LD_LIBRARY_PATH"] = ":".join( [self.xrePath, env["LD_LIBRARY_PATH"]]) args = [ "-g", self.xrePath, "-f", os.path.join(self.httpdPath, "httpd.js"), "-e", "const _PROFILE_PATH = '%(profile)s';const _SERVER_PORT = " "'%(port)s'; const _SERVER_ADDR ='%(server)s';" % { "profile": self.profileDir.replace("\\", "\\\\"), "port": self.httpPort, "server": self.webServer, }, "-f", os.path.join(self.scriptDir, "server.js"), ] xpcshell = os.path.join(self.utilityPath, "xpcshell" + bin_suffix) if not os.access(xpcshell, os.F_OK): raise Exception("xpcshell not found at %s" % xpcshell) if RemoteAutomation.elf_arm(xpcshell): raise Exception("xpcshell at %s is an ARM binary; please use " "the --utility-path argument to specify the path " "to a desktop version." % xpcshell) self._process = subprocess.Popen([xpcshell] + args, env=env) pid = self._process.pid if pid < 0: self.log.error( "TEST-UNEXPECTED-FAIL | remotereftests.py | Error starting server." ) return 2 self.log.info("INFO | remotereftests.py | Server pid: %d" % pid)