OLD | NEW |
(Empty) | |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 """Start and stop the WPTserve servers as they're used by the layout tests.""" |
| 6 |
| 7 from webkitpy.layout_tests.servers import server_base |
| 8 |
| 9 |
| 10 class WPTServe(server_base.ServerBase): |
| 11 def __init__(self, port_obj, output_dir): |
| 12 super(WPTServe, self).__init__(port_obj, output_dir) |
| 13 # These ports must match wpt_support/wpt.config.json |
| 14 http_port, http_alt_port, https_port = (8001, 8081, 8444) |
| 15 ws_port, wss_port = (9001, 9444) |
| 16 self._name = 'wptserve' |
| 17 self._log_prefixes = ('access_log', 'error_log') |
| 18 self._mappings = [{'port': http_port}, |
| 19 {'port': http_alt_port}, |
| 20 {'port': https_port, 'sslcert': True}, |
| 21 {'port': ws_port}, |
| 22 {'port': wss_port, 'sslcert': True}] |
| 23 |
| 24 # TODO(burnik): We can probably avoid PID files for WPT in the future. |
| 25 fs = self._filesystem |
| 26 self._pid_file = fs.join(self._runtime_path, '%s.pid' % self._name) |
| 27 |
| 28 path_to_thirdparty = self._port_obj.path_from_webkit_base('Tools', 'Scri
pts', 'webkitpy', 'thirdparty') |
| 29 path_to_wpt_support = self._port_obj.path_from_webkit_base('Tools', 'Scr
ipts', 'webkitpy', 'thirdparty', 'wpt') |
| 30 path_to_wpt_root = fs.join(path_to_wpt_support, 'wpt') |
| 31 path_to_wpt_config = fs.join(path_to_wpt_support, 'wpt.config.json') |
| 32 path_to_wpt_tests = fs.abspath(fs.join(self._port_obj.layout_tests_dir()
, 'imported', 'web-platform-tests')) |
| 33 path_to_ws_handlers = fs.join(path_to_wpt_tests, 'websockets', 'handlers
') |
| 34 serve_script = fs.join(path_to_wpt_root, 'serve') |
| 35 start_cmd = [self._port_obj.host.executable, |
| 36 '-u', serve_script, |
| 37 '--config', path_to_wpt_config, |
| 38 '--doc_root', path_to_wpt_tests] |
| 39 |
| 40 # TODO(burnik): Merge with default start_cmd once we roll in websockets. |
| 41 if self._port_obj.host.filesystem.exists(path_to_ws_handlers): |
| 42 start_cmd += ['--ws_doc_root', path_to_ws_handlers] |
| 43 |
| 44 self._stdout = self._stderr = self._executive.DEVNULL |
| 45 # TODO(burnik): We should stop setting the CWD once WPT can be run witho
ut it. |
| 46 self._cwd = path_to_wpt_root |
| 47 self._env = {'PYTHONPATH': path_to_thirdparty} |
| 48 self._keep_process_reference = True |
| 49 self._start_cmd = start_cmd |
| 50 |
| 51 def _stop_running_server(self): |
| 52 # Clean up the pid file. |
| 53 if self._pid and not self._executive.check_running_pid(self._pid): |
| 54 self._filesystem.remove(self._pid_file) |
| 55 return |
| 56 |
| 57 # TODO(burnik): Figure out a cleaner way of stopping wptserve. |
| 58 self._executive.interrupt(self._pid) |
| 59 |
| 60 # According to Popen.wait(), this can deadlock when using stdout=PIPE an
d/or stderr=PIPE. |
| 61 # We're using DEVNULL for both so that should not occur. |
| 62 self._process.wait() |
OLD | NEW |