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

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: Add additional README for maintenance. 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 sys
10 import socket
11
12 from webkitpy.layout_tests.servers import server_base
13
14
15 _log = logging.getLogger(__name__)
16
17
18 class WPTServe(server_base.ServerBase):
19 def __init__(self, port_obj, output_dir):
20 super(WPTServe, self).__init__(port_obj, output_dir)
21 # These ports must match wpt_support/wpt.config.json
22 http_port, http_alt_port, https_port = (8001, 8081, 8444)
23 ws_port, wss_port = (9001, 9444)
24 self._name = 'wptserve'
25 self._log_prefixes = ('access_log', 'error_log')
26 self._mappings = [{'port': http_port},
27 {'port': http_alt_port},
28 {'port': https_port, 'sslcert': True},
29 {'port': ws_port},
30 {'port': wss_port, 'sslcert': True}]
31
32 # TODO(burnik): We can probably avoid PID files for WPT in the future.
33 self._pid_file = self._filesystem.join(self._runtime_path, '%s.pid' % se lf._name)
34
35 self._path_to_thirdparty = self._port_obj.path_from_webkit_base('Tools', 'Scripts', 'webkitpy', 'thirdparty')
36 self._executive.pythonpath.append(self._path_to_thirdparty)
37 self._executive.pythonpath.update()
Dirk Pranke 2015/06/12 22:25:02 You don't need this. If you set self._env = {'P
burnik 2015/06/15 10:35:09 Done.
38 path_to_wpt_support = self._port_obj.path_from_webkit_base('Tools', 'Scr ipts', 'webkitpy', 'thirdparty', 'wpt')
39 self._path_to_wpt_root = os.path.join(path_to_wpt_support, 'wpt')
Dirk Pranke 2015/06/12 22:25:01 Use self._filesystemm.join() instead of os.path.jo
burnik 2015/06/15 10:35:10 Done.
40 self._executable = os.path.join(self._path_to_wpt_root, 'serve')
41 path_to_wpt_config = os.path.join(path_to_wpt_support, 'wpt.config.json' )
42 path_to_wpt_tests = os.path.abspath(os.path.join(self._port_obj.layout_t ests_dir(),
43 'imported', 'web-platfo rm-tests'))
44 path_to_ws_handlers = os.path.join(path_to_wpt_tests, 'websockets', 'han dlers')
45 start_cmd = [self._executable,
Dirk Pranke 2015/06/12 22:25:02 This should be start_cmd = [self.port_obj.ho
burnik 2015/06/15 10:35:09 Done.
46 '--config', path_to_wpt_config,
47 '--doc_root', path_to_wpt_tests]
48
49 # TODO(burnik): Merge with default start_cmd once we roll in websockets.
50 if self._port_obj.host.filesystem.exists(path_to_ws_handlers):
51 start_cmd += ['--ws_doc_root', path_to_ws_handlers]
52
53 self._start_cmd = start_cmd
54
55 def _spawn_process(self):
Dirk Pranke 2015/06/12 22:25:02 As noted above, let's see if we can make the base
burnik 2015/06/15 10:35:10 Done.
56 _log.debug('Starting %s server, cmd="%s"' % (self._name, str(self._start _cmd)))
57 self._process = self._executive.popen(' '.join(self._start_cmd),
58 cwd=self._path_to_wpt_root,
59 shell=True,
60 stdout=self._executive.DEVNULL,
61 stderr=self._executive.DEVNULL,
62 preexec_fn=os.setsid)
Dirk Pranke 2015/06/12 22:25:01 AFAICT, you don't need (and don't want) os.setsid
burnik 2015/06/15 10:35:10 It had to do with kill_process when killing a grou
63
64 # We probably won't need a PID file, but server_base needs it.
65 fs = self._port_obj.host.filesystem
66 fs.write_text_file(self._pid_file, str(self._process.pid))
67 return self._process.pid
68
69 def stop(self):
70 self._stop_running_server()
Dirk Pranke 2015/06/12 22:25:01 I don't think you need to override the base class
burnik 2015/06/15 10:35:09 Done.
71
72 def _stop_running_server(self):
73 # Clean up the pid file.
74 if self._pid and not self._executive.check_running_pid(self._pid):
75 self._filesystem.remove(self._pid_file)
76 return
77
78 self._executive.pythonpath.remove(self._path_to_thirdparty)
79 self._executive.pythonpath.update()
80
81 # TODO(burnik): Figure out a cleaner way of stopping wptserve.
82 self._executive.interrupt(self._pid)
Dirk Pranke 2015/06/12 22:25:01 We might need to add another hook to ServerBase so
burnik 2015/06/15 10:35:09 Actually we would need two hooks. One telling the
83
84 # According to Popen.wait(), this can deadlock when using stdout=PIPE an d/or stderr=PIPE.
85 # We're using DEVNULL for both so that should not occur.
86 self._process.wait()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698