Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(468)

Side by Side Diff: Tools/Scripts/webkitpy/layout_tests/servers/wptserve.py

Issue 1154373005: Introduce WPTServe for running W3C Blink Layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Check in WPTServe files. Update checkout script. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 import logging
8 import os
9 import socket
10
11 from webkitpy.layout_tests.servers import server_base
12
13
14 _log = logging.getLogger(__name__)
15
16
17 class WPTServe(server_base.ServerBase):
18 def __init__(self, port_obj, output_dir):
19 super(WPTServe, self).__init__(port_obj, output_dir)
20 # These ports must match wpt_support/wpt.config.json
21 http_port, http_alt_port, https_port = (8001, 8081, 8444)
22 ws_port, wss_port = (9001, 9444)
23 self._name = 'wptserve'
24 self._log_prefixes = ('access_log', 'error_log')
25 self._mappings = [{'port': http_port},
26 {'port': http_alt_port},
27 {'port': https_port, 'sslcert': True},
28 {'port': ws_port},
29 {'port': wss_port, 'sslcert': True}]
30
31 # TODO(burnik): We can probably avoid PID files for WPT in the future.
32 self._pid_file = self._filesystem.join(self._runtime_path, '%s.pid' % se lf._name)
33
34 script_path = os.path.dirname(os.path.abspath(__file__))
35 path_to_wpt_support = os.path.join(script_path, 'wpt_support')
36 self._path_to_wpt = os.path.join(path_to_wpt_support, 'wpt')
37 self._executable = os.path.join(self._path_to_wpt, 'serve')
38 path_to_wpt_config = os.path.join(path_to_wpt_support, 'wpt.config.json' )
39 path_to_wpt_tests = os.path.abspath(os.path.join(self._port_obj.layout_t ests_dir(),
40 'imported', 'web-platfo rm-tests'))
41 path_to_ws_handlers = os.path.join(path_to_wpt_tests, 'websockets', 'han dlers')
42 start_cmd = [self._executable,
43 '--config', path_to_wpt_config,
44 '--doc_root', path_to_wpt_tests]
45
46 # TODO(burnik): Merge with default start_cmd once we roll in websockets.
47 if self._port_obj.host.filesystem.exists(path_to_ws_handlers):
48 start_cmd += ['--ws_doc_root', path_to_ws_handlers]
49
50 self._start_cmd = start_cmd
51
52 def _spawn_process(self):
53 _log.debug('Starting %s server, cmd="%s"' % (self._name, str(self._start _cmd)))
54 self._process = self._executive.popen(' '.join(self._start_cmd),
55 cwd=self._path_to_wpt,
56 shell=True,
57 stdout=self._executive.DEVNULL,
58 stderr=self._executive.DEVNULL,
59 preexec_fn=os.setsid)
60
61 # We probably won't need a PID file, but server_base needs it.
62 fs = self._port_obj.host.filesystem
63 fs.write_text_file(self._pid_file, str(self._process.pid))
64 return self._process.pid
65
66 def stop(self):
67 self._stop_running_server()
68
69 def _stop_running_server(self):
70 # Clean up the pid file.
71 if self._pid and not self._executive.check_running_pid(self._pid):
72 self._filesystem.remove(self._pid_file)
73 return
74
75 # TODO(burnik): Figure out a cleaner way of stopping wptserve.
76 self._executive.interrupt(self._pid)
77
78 # According to Popen.wait(), this can deadlock when using stdout=PIPE an d/or stderr=PIPE.
79 # We're using DEVNULL for both so that should not occur.
80 self._process.wait()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698