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

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

Issue 1154373005: Introduce WPTServe for running W3C Blink Layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: USE 127.0.0.1 as WPT host. Skip checking subdomains. 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
1 # Copyright (C) 2011 Google Inc. All rights reserved. 1 # Copyright (C) 2011 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 # Subclasses must override these fields. 66 # Subclasses must override these fields.
67 self._name = '<virtual>' 67 self._name = '<virtual>'
68 self._log_prefixes = tuple() 68 self._log_prefixes = tuple()
69 self._mappings = {} 69 self._mappings = {}
70 self._pid_file = None 70 self._pid_file = None
71 self._start_cmd = None 71 self._start_cmd = None
72 72
73 # Subclasses may override these fields. 73 # Subclasses may override these fields.
74 self._env = None 74 self._env = None
75 self._cwd = None
75 self._stdout = self._executive.PIPE 76 self._stdout = self._executive.PIPE
76 self._stderr = self._executive.PIPE 77 self._stderr = self._executive.PIPE
78 self._keep_process_reference = False
77 self._process = None 79 self._process = None
Dirk Pranke 2015/06/15 23:41:48 This seems a bit off; we actually define a self._p
burnik 2015/06/16 09:24:34 Done. Hope it doesn't break anything...
78 self._pid = None 80 self._pid = None
79 self._error_log_path = None 81 self._error_log_path = None
80 82
81 def start(self): 83 def start(self):
82 """Starts the server. It is an error to start an already started server. 84 """Starts the server. It is an error to start an already started server.
83 85
84 This method also stops any stale servers started by a previous instance. """ 86 This method also stops any stale servers started by a previous instance. """
85 assert not self._pid, '%s server is already running' % self._name 87 assert not self._pid, '%s server is already running' % self._name
86 88
87 # Stop any stale servers left over from previous instances. 89 # Stop any stale servers left over from previous instances.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 delete the logs will actually cause start() to fail.""" 157 delete the logs will actually cause start() to fail."""
156 # Sometimes logs are open in other processes but they should clear event ually. 158 # Sometimes logs are open in other processes but they should clear event ually.
157 for log_prefix in self._log_prefixes: 159 for log_prefix in self._log_prefixes:
158 try: 160 try:
159 self._remove_log_files(self._output_dir, log_prefix) 161 self._remove_log_files(self._output_dir, log_prefix)
160 except OSError, e: 162 except OSError, e:
161 _log.warning('Failed to remove old %s %s files' % (self._name, l og_prefix)) 163 _log.warning('Failed to remove old %s %s files' % (self._name, l og_prefix))
162 164
163 def _spawn_process(self): 165 def _spawn_process(self):
164 _log.debug('Starting %s server, cmd="%s"' % (self._name, self._start_cmd )) 166 _log.debug('Starting %s server, cmd="%s"' % (self._name, self._start_cmd ))
165 process = self._executive.popen(self._start_cmd, env=self._env, stdout=s elf._stdout, stderr=self._stderr) 167 process = self._executive.popen(self._start_cmd,
168 env=self._env,
169 cwd=self._cwd,
170 stdout=self._stdout,
171 stderr=self._stderr)
172 if self._keep_process_reference:
173 self._process = process
174
166 pid = process.pid 175 pid = process.pid
167 self._filesystem.write_text_file(self._pid_file, str(pid)) 176 self._filesystem.write_text_file(self._pid_file, str(pid))
168 return pid 177 return pid
169 178
170 def _stop_running_server(self): 179 def _stop_running_server(self):
171 self._wait_for_action(self._check_and_kill) 180 self._wait_for_action(self._check_and_kill)
172 if self._filesystem.exists(self._pid_file): 181 if self._filesystem.exists(self._pid_file):
173 self._filesystem.remove(self._pid_file) 182 self._filesystem.remove(self._pid_file)
174 183
175 def _check_and_kill(self): 184 def _check_and_kill(self):
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 except IOError, e: 278 except IOError, e:
270 if e.errno in (errno.EALREADY, errno.EADDRINUSE): 279 if e.errno in (errno.EALREADY, errno.EADDRINUSE):
271 raise ServerError('Port %d is already in use.' % port) 280 raise ServerError('Port %d is already in use.' % port)
272 elif self._platform.is_win() and e.errno in (errno.WSAEACCES,): # pylint: disable=E1101 281 elif self._platform.is_win() and e.errno in (errno.WSAEACCES,): # pylint: disable=E1101
273 raise ServerError('Port %d is already in use.' % port) 282 raise ServerError('Port %d is already in use.' % port)
274 else: 283 else:
275 raise 284 raise
276 finally: 285 finally:
277 s.close() 286 s.close()
278 _log.debug('all ports are available') 287 _log.debug('all ports are available')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698