def test_main(self): def mock_server_constructor(*args, **kwargs): self.server = MockServer(args, kwargs) return self.server cli_wrapper.main(mock_server_constructor, input_fn=lambda msg: True, argv=[]) self.assertTrue(self.server.start_called) self.assertTrue(self.server.stop_called)
def test_main_success(self): def mock_server_constructor(*args, **kwargs): self.server = MockServer(args, kwargs) return self.server def raise_exit(): raise SystemExit cli_wrapper.main(mock_server_constructor, sleep_fn=raise_exit, argv=[]) self.assertTrue(self.server.start_called) self.assertTrue(self.server.stop_called)
def test_main_server_error_after_start(self): def mock_server_constructor(*args, **kwargs): self.server = MockServer(args, kwargs) return self.server def server_error(): self.server.is_alive = False cli_wrapper.main(mock_server_constructor, sleep_fn=server_error, argv=[]) self.assertTrue(self.server.start_called) self.assertTrue(self.server.stop_called)
#!/usr/bin/env vpython # Copyright 2015 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Runs an instance of wptserve to allow manual testing of web-platform-tests. The main HTTP server is run on 8001, while the main HTTPS server is run on 8444. URL paths are relative to the web-platform-tests root, e.g. the test: web_tests/external/wpt/referrer-policy/origin/http-rp/same-origin/http-http/img-tag/generic.no-redirect.http.html Could be tried by running this scrip then navigating to: http://localhost:8001/referrer-policy/origin/http-rp/same-origin/http-http/img-tag/generic.no-redirect.http.html """ from blinkpy.common import version_check # pylint: disable=unused-import from blinkpy.web_tests.servers import cli_wrapper from blinkpy.web_tests.servers import wptserve print( "Generated content (out/BUILD_DIR/gen) is *only* served from " "out/Release/gen. It is possible to symlink a gen dir from another build " "directory.") cli_wrapper.main(wptserve.WPTServe, description=__doc__)
# this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Runs a WebSocket server for WebSocket tests. Some tests require both an HTTP server and WebSocket server. You can start both servers by running both run_blink_httpd.py and run_blink_websocketserver.py. Tests served by the HTTP server have paths relative to web_tests/http/tests/. For example, to run a test http/tests/websocket/binary-type.html which depends on WebSocket, you can navigate to: http://127.0.0.1:8000/websocket/close-unref-websocket.html """ from blinkpy.common import version_check # pylint: disable=unused-import from blinkpy.web_tests.servers import cli_wrapper from blinkpy.web_tests.servers import pywebsocket cli_wrapper.main(pywebsocket.PyWebSocket, description=__doc__)
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Runs an Apache HTTP server to manually run web tests locally. After running this script, you can locally navigate to URLs where the path is relative to web_tests/http/tests/. For example, to run web_tests/http/tests/cachestorage/window-cache-add.html, navigate to: http://127.0.0.1:8000/cachestorage/window/cache-add.html When using HTTPS, for example: https://127.0.0.1:8443/https/verify-ssl-enabled.php you will may a certificate warning, which you need to bypass. After starting the server, you can also run individual web tests via content_shell, e.g. $ out/Release/content_shell --run-web-tests \ http://127.0.0.1:8000/security/cross-frame-access-get.html Note that some tests will only work if "127.0.0.1" for the host part of the URL, rather than "localhost". """ from blinkpy.common import version_check # pylint: disable=unused-import from blinkpy.web_tests.servers import cli_wrapper from blinkpy.web_tests.servers import apache_http cli_wrapper.main(apache_http.ApacheHTTP, additional_dirs={}, number_of_servers=4, description=__doc__)
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Runs a WebSocket server for WebSocket tests. Some tests require both an HTTP server and WebSocket server. You can start both servers by running both run_blink_httpd.py and run_blink_websocketserver.py. Tests served by the HTTP server have paths relative to web_tests/http/tests/. For example, to run a test http/tests/websocket/binary-type.html which depends on WebSocket, you can navigate to: http://127.0.0.1:8000/websocket/close-unref-websocket.html """ import sys import optparse from blinkpy.common import version_check # pylint: disable=unused-import from blinkpy.web_tests.servers import cli_wrapper from blinkpy.web_tests.servers import pywebsocket option, args = cli_wrapper.parse_python_server_options() cli_wrapper.main(pywebsocket.PyWebSocket, argv=args, description=__doc__, python_executable=option.python_executable)