Update web-platform-tests to revision d04a8fc02b85bd32799691759c8c05ead07cd939

This commit is contained in:
WPT Sync Bot 2018-03-23 21:12:55 -04:00
parent e8fdc677f4
commit 2b35c55ac7
63 changed files with 2068 additions and 340 deletions

View file

@ -1,48 +1,49 @@
import json
import os
import ssl
import subprocess
import time
import urllib2
_CONFIG_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'config.test.json')
with open(_CONFIG_FILE, 'r') as config_handle:
config = json.loads(config_handle.read())
host = config["host"]
port = config["ports"]["https"][0]
class WPTServer(object):
base_url = 'https://%s:%s' % (host, port)
def __init__(self, wpt_root):
self.wpt_root = wpt_root
with open(_CONFIG_FILE, 'r') as config_handle:
config = json.load(config_handle)
self.host = config["host"]
self.http_port = config["ports"]["http"][0]
self.https_port = config["ports"]["https"][0]
self.base_url = 'http://%s:%s' % (self.host, self.http_port)
self.https_base_url = 'https://%s:%s' % (self.host, self.https_port)
def start(self):
self.devnull = open(os.devnull, 'w')
self.proc = subprocess.Popen(
[os.path.join(self.wpt_root, 'wpt'), 'serve', '--config=' + _CONFIG_FILE],
stdout=self.devnull,
stderr=self.devnull,
cwd=self.wpt_root)
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
context.verify_mode = ssl.CERT_NONE
context.check_hostname = False
while True:
for retry in range(5):
# Exponential backoff.
time.sleep(2 ** retry)
if self.proc.poll() != None:
raise Exception('Could not start wptserve.')
try:
urllib2.urlopen(self.base_url, timeout=1, context=context)
break
except urllib2.URLError as e:
try:
urllib2.urlopen(self.base_url, timeout=1)
return
except urllib2.URLError:
pass
raise Exception('Could not start wptserve.')
def stop(self):
self.proc.kill()
self.proc.terminate()
self.proc.wait()
self.devnull.close()
def url(self, abs_path):
return self.base_url + '/' + os.path.relpath(abs_path, self.wpt_root)
return self.https_base_url + '/' + os.path.relpath(abs_path, self.wpt_root)