def main(self):
        kwargs = vars(serve.get_parser().parse_args())

        # Configuration script to setup server used for serving web platform tests.
        config = serve.load_config(
            os.path.join(WPT_DIR, 'config.default.json'),
            os.path.join(WPT_DIR, 'config.json'), **kwargs)
        config['ports']['http'][0] = int(self._wpt_http_port)

        serve.setup_logger(config['log_level'])

        with stash.StashServer((self._binding_address, serve.get_port()),
                               authkey=str(uuid.uuid4())):
            with serve.get_ssl_environment(config) as ssl_env:
                _, self._servers = serve.start(config, ssl_env,
                                               serve.default_routes(),
                                               **kwargs)
                self._server_started = True

                try:
                    while any(item.is_alive()
                              for item in serve.iter_procs(self._servers)):
                        for item in serve.iter_procs(self._servers):
                            item.join(1)
                except KeyboardInterrupt:
                    serve.logger.info('Shutting down')
Example #2
0
def main(argv, stdout, stderr):
    # This is a copy of serve.py main function, except for the wait step
    config = WebPlatformTestServer.load_config("config.default.json",
                                               "config.json")
    WebPlatformTestServer.setup_logger(config["log_level"])
    logged_servers = []

    with stash.StashServer((config["host"], WebPlatformTestServer.get_port()),
                           authkey=str(uuid.uuid4())):
        with WebPlatformTestServer.get_ssl_environment(config) as ssl_env:
            config_, started_servers = WebPlatformTestServer.start(
                config, ssl_env, WebPlatformTestServer.default_routes())

            for protocol, servers in started_servers.items():
                for port, process in servers:
                    logged_servers.append({
                        "protocol": protocol,
                        "port": port,
                        "pid": process.proc.pid
                    })
                    logger.info("%s, port:%d, pid:%d" %
                                (protocol, port, process.proc.pid))

            # Write pids in a file in case abrupt shutdown is needed
            with open(argv[0], "wb") as servers_file:
                json.dump(logged_servers, servers_file)

            sys.stdin.read(1)
Example #3
0
    def get_routes(self):
        routes = serve.default_routes()
        for path, format_args, content_type, route in [
                ("testharness_runner.html", {}, "text/html", "/testharness_runner.html"),
                (self.options.get("testharnessreport", "testharnessreport.js"),
                 {"output": self.pause_after_test}, "text/javascript",
                 "/resources/testharnessreport.js")]:
            handler = StaticHandler(os.path.join(here, path), format_args, content_type)
            routes.insert(0, (b"GET", str(route), handler))

        for url, paths in self.test_paths.iteritems():
            if url == "/":
                continue

            path = paths["tests_path"]
            url = "/%s/" % url.strip("/")

            for (method,
                 suffix,
                 handler_cls) in [(b"*",
                                   b"*.py",
                                   serve.handlers.PythonScriptHandler),
                                  (b"GET",
                                   "*.asis",
                                   serve.handlers.AsIsHandler),
                                  (b"GET",
                                   "*",
                                   serve.handlers.FileHandler)]:
                route = (method, b"%s%s" % (str(url), str(suffix)), handler_cls(path, url_base=url))
                routes.insert(-3, route)

        if "/" not in self.test_paths:
            routes = routes[:-3]

        return routes
def main(argv, stdout, stderr):
    # This is a copy of serve.py main function, except for the wait step
    config = WebPlatformTestServer.load_config("config.default.json", "config.json")
    WebPlatformTestServer.setup_logger(config["log_level"])
    logged_servers = []

    with stash.StashServer((config["host"], WebPlatformTestServer.get_port()), authkey=str(uuid.uuid4())):
        with WebPlatformTestServer.get_ssl_environment(config) as ssl_env:
            config_, started_servers = WebPlatformTestServer.start(config, ssl_env, WebPlatformTestServer.default_routes())

            for protocol, servers in started_servers.items():
                for port, process in servers:
                    logged_servers.append({"protocol": protocol, "port": port, "pid": process.proc.pid})
                    logger.info("%s, port:%d, pid:%d" % (protocol, port, process.proc.pid))

    # Write pids in a file in case abrupt shutdown is needed
    with open(argv[0], "wb") as servers_file:
        json.dump(logged_servers, servers_file)

    sys.stdin.read(1)