Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make wptserve work from outside repo root #10125

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@jgraham
Copy link
Contributor

jgraham commented Mar 21, 2018

Previously it was assumed that the paths in config files were relative
to the current working directory, which only works if the current
working directory happens to be the repo root. With this change we
make them paths relative to some base path. We typically expect this
to be set to the path of the config file, but for the default case we
also know that the config files are in the repo root, so we can use that.

This change is Reviewable

commit f712edbaad27ef27fde23681673a8e7b2e4b8534
Author: James Graham <james@hoppipolla.co.uk>
Date:   Fri Mar 16 13:25:58 2018 +0000

    Bug 1446374 - Make wptserve work from outside repo root, r=gsnedders

    Previously it was assumed that the paths in config files were relative
    to the current working directory, which only works if the current
    working directory happens to be the repo root. With this change we
    make them paths relative to some base path. We typically expect this
    to be set to the path of the config file, but for the default case we
    also know that the config files are in the repo root, so we can use that.

    MozReview-Commit-ID: 8pR8VGmB81d

diff --git a/testing/web-platform/tests/tools/serve/serve.py b/testing/web-platform/tests/tools/serve/serve.py
index c77badc2682c..41590a82f457 100644
--- a/testing/web-platform/tests/tools/serve/serve.py
+++ b/testing/web-platform/tests/tools/serve/serve.py
@@ -17,7 +17,7 @@ import uuid
 from collections import defaultdict, OrderedDict
 from multiprocessing import Process, Event

-from ..localpaths import repo_root
+from localpaths import repo_root

 import sslutils
 from manifest.sourcefile import read_script_metadata, js_meta_re
@@ -622,8 +622,7 @@ def get_ports(config, ssl_environment):
     return rv

-
-def normalise_config(config, ports):
+def normalise_config(config, ports, base_path=repo_root):
     host = config["external_host"] if config["external_host"] else config["host"]
     domains = get_subdomains(host)
     ports_ = {}
@@ -645,6 +644,20 @@ def normalise_config(config, ports):
     config_["host"] = host
     config_["domains"] = domains
     config_["ports"] = ports_
+
+    path_properties = ["doc_root",
+                       "ws_doc_root",
+                       ("ssl", "openssl", "base_path"),
+                       ("ssl", "pregenerated", "host_key_path"),
+                       ("ssl", "pregenerated", "host_cert_path")]
+    for key in path_properties:
+        target = config_
+        if not isinstance(key, (str, unicode)):
+            for key_part in key[:-1]:
+                target = target[key_part]
+            key = key[-1]
+        target[key] = os.path.join(base_path, target[key])
+
     return config_

@@ -653,13 +666,14 @@ def get_paths(config):
             "ws_doc_root": config["ws_doc_root"]}

-def get_ssl_config(config, ssl_environment):
+def get_ssl_config(config, ssl_environment, base_path=repo_root):
     external_domains = config["domains"].values()
     key_path, cert_path = ssl_environment.host_cert_path(external_domains)
-    return {"key_path": key_path,
-            "cert_path": cert_path,
+    return {"key_path": os.path.join(base_path, key_path),
+            "cert_path": os.path.join(base_path, cert_path),
             "encrypt_after_connect": config["ssl"]["encrypt_after_connect"]}

+
 def start(config, ssl_environment, routes, **kwargs):
     host = config["host"]
     ports = get_ports(config, ssl_environment)
@@ -783,7 +797,7 @@ def run(**kwargs):

     with get_ssl_environment(config) as ssl_env:
         ports = get_ports(config, ssl_env)
-        config = normalise_config(config, ports)
+        config = normalise_config(config, ports, repo_root)
         host = config["host"]
         bind_hostname = config["bind_hostname"]

@jgraham jgraham requested a review from gsnedders Mar 21, 2018

@wpt-pr-bot wpt-pr-bot added the infra label Mar 21, 2018

@w3c-bots

This comment has been minimized.

Copy link

w3c-bots commented Mar 21, 2018

Build ERRORED

Started: 2018-03-21 16:12:29
Finished: 2018-03-21 16:28:20

Failing Jobs

  • tools_unittest in py36
  • wpt_integration in py27,py27-flake8

View more information about this build on:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.