diff --git a/tests/end2end/data/userscripts/echo.bat b/tests/end2end/data/userscripts/echo.bat new file mode 100644 index 000000000..0f37ae2cd --- /dev/null +++ b/tests/end2end/data/userscripts/echo.bat @@ -0,0 +1,6 @@ +@echo off +rem This is needed because echo does not exist as an external program on +rem Windows, so we can't call echo(.exe) from qutebrowser, but it's useful for +rem tests. This little file is callable via :spawn and mimics (in a very naive +rem way) the echo command line utility. +echo %* diff --git a/tests/end2end/features/conftest.py b/tests/end2end/features/conftest.py index 100c15f0c..1dccf6d6e 100644 --- a/tests/end2end/features/conftest.py +++ b/tests/end2end/features/conftest.py @@ -19,6 +19,7 @@ """Steps for bdd-like tests.""" +import os import re import sys import time @@ -34,6 +35,18 @@ from qutebrowser.utils import log from helpers import utils +def get_echo_exe_path(): + """Return the path to an echo-like command, depending on the system. + + Return: + Path to the "echo"-utility. + """ + if sys.platform == "win32": + return os.path.join(utils.abs_datapath(), 'userscripts', 'echo.bat') + else: + return 'echo' + + @pytest.hookimpl(hookwrapper=True) def pytest_runtest_makereport(item, call): """Add a BDD section to the test output.""" @@ -215,6 +228,7 @@ def run_command(quteproc, httpbin, tmpdir, command): command = command.replace('(port)', str(httpbin.port)) command = command.replace('(testdata)', utils.abs_datapath()) command = command.replace('(tmpdir)', str(tmpdir)) + command = command.replace('(echo-exe)', get_echo_exe_path()) quteproc.send_cmd(command, count=count, invalid=invalid) diff --git a/tests/end2end/features/spawn.feature b/tests/end2end/features/spawn.feature index 469120cc2..5cdeac029 100644 --- a/tests/end2end/features/spawn.feature +++ b/tests/end2end/features/spawn.feature @@ -1,7 +1,7 @@ Feature: :spawn Scenario: Running :spawn - When I run :spawn -v echo "Hello" + When I run :spawn -v (echo-exe) "Hello" Then the message "Command exited successfully." should be shown Scenario: Running :spawn with command that does not exist @@ -19,18 +19,18 @@ Feature: :spawn Then the error "Error while splitting command: No closing quotation" should be shown Scenario: Running :spawn with url variable - When I run :spawn echo {url} - Then "Executing echo with args ['about:blank'], userscript=False" should be logged + When I run :spawn (echo-exe) {url} + Then "Executing * with args ['about:blank'], userscript=False" should be logged Scenario: Running :spawn with url variable in fully encoded format When I open data/title with spaces.html - And I run :spawn echo {url} - Then "Executing echo with args ['http://localhost:(port)/data/title%20with%20spaces.html'], userscript=False" should be logged + And I run :spawn (echo-exe) {url} + Then "Executing * with args ['http://localhost:(port)/data/title%20with%20spaces.html'], userscript=False" should be logged Scenario: Running :spawn with url variable in pretty decoded format When I open data/title with spaces.html - And I run :spawn echo {url:pretty} - Then "Executing echo with args ['http://localhost:(port)/data/title with spaces.html'], userscript=False" should be logged + And I run :spawn (echo-exe) {url:pretty} + Then "Executing * with args ['http://localhost:(port)/data/title with spaces.html'], userscript=False" should be logged @posix Scenario: Running :spawn with userscript