From 0300f03ebc094103620a355369137c581fcd9dde Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Thu, 19 May 2016 20:37:57 -0400 Subject: [PATCH 1/5] Allow passing args to spawn from :hint. Instead of creating a new guiprocess manually, just pass the args along to the spawn command so it can accept args like -v. Addresses part of #797 by allowing `hint -- all spawn -v echo`. `hint all spawn -v echo` is still not supported. --- qutebrowser/browser/hints.py | 6 ++---- tests/integration/features/hints.feature | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index 69252f106..6a09274a6 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -36,7 +36,6 @@ from qutebrowser.keyinput import modeman, modeparsers from qutebrowser.browser import webelem from qutebrowser.commands import userscripts, cmdexc, cmdutils, runners from qutebrowser.utils import usertypes, log, qtutils, message, objreg, utils -from qutebrowser.misc import guiprocess ElemTuple = collections.namedtuple('ElemTuple', ['elem', 'label']) @@ -625,9 +624,8 @@ class HintManager(QObject): """ urlstr = url.toString(QUrl.FullyEncoded | QUrl.RemovePassword) args = context.get_args(urlstr) - cmd, *args = args - proc = guiprocess.GUIProcess(self._win_id, what='command', parent=self) - proc.start(cmd, args) + commandrunner = runners.CommandRunner(self._win_id) + commandrunner.run_safely('spawn ' + ' '.join(args)) def _resolve_url(self, elem, baseurl): """Resolve a URL and check if we want to keep it. diff --git a/tests/integration/features/hints.feature b/tests/integration/features/hints.feature index 4d4519fdd..a6be75abc 100644 --- a/tests/integration/features/hints.feature +++ b/tests/integration/features/hints.feature @@ -44,6 +44,12 @@ Feature: Using hints And I run :fake-key -g Then no crash should happen + Scenario: Using :hint spawn with flags and -- (issue 797) + When I open data/hints/link.html + And I run :hint -- all spawn -v echo + And I run :follow-hint a + Then the message "Command exited successfully." should be shown + @xfail Scenario: Using :hint spawn with flags (issue 797) When I open data/hints/html/simple.html From f025394e047a8579a249847b67825c5581a120b2 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Thu, 19 May 2016 20:42:22 -0400 Subject: [PATCH 2/5] Set maxsplit=2 for :hint. This supports things like :hint all spawn -v echo as '-v echo' will be passed as a single unit to spawn rather than -v being interpreted as a flag for :hint. Resolves #797. Note that, while `:hint --rapid all spawn -v` echo works, `:hint all --rapid spawn -v echo` does not (this did not work before either). --- qutebrowser/browser/hints.py | 2 +- tests/integration/features/hints.feature | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index 6a09274a6..cff7ce724 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -779,7 +779,7 @@ class HintManager(QObject): webview.openurl(url) @cmdutils.register(instance='hintmanager', scope='tab', name='hint', - star_args_optional=True) + star_args_optional=True, maxsplit=2) @cmdutils.argument('win_id', win_id=True) def start(self, rapid=False, group=webelem.Group.all, target=Target.normal, *args, win_id): diff --git a/tests/integration/features/hints.feature b/tests/integration/features/hints.feature index a6be75abc..f8a77212f 100644 --- a/tests/integration/features/hints.feature +++ b/tests/integration/features/hints.feature @@ -50,12 +50,11 @@ Feature: Using hints And I run :follow-hint a Then the message "Command exited successfully." should be shown - @xfail Scenario: Using :hint spawn with flags (issue 797) When I open data/hints/html/simple.html And I run :hint all spawn -v echo And I run :follow-hint a - Then the message "Command exited successfully" should be shown + Then the message "Command exited successfully." should be shown Scenario: Yanking to primary selection without it being supported (#1336) When selection is not supported From 87cb5bf6c23feb124ea64d736a2c5a81ceb7554e Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Fri, 20 May 2016 22:13:49 -0400 Subject: [PATCH 3/5] Fix test html link for hints --- tests/integration/features/hints.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/features/hints.feature b/tests/integration/features/hints.feature index f8a77212f..1e3001c0b 100644 --- a/tests/integration/features/hints.feature +++ b/tests/integration/features/hints.feature @@ -45,7 +45,7 @@ Feature: Using hints Then no crash should happen Scenario: Using :hint spawn with flags and -- (issue 797) - When I open data/hints/link.html + When I open data/hints/simple.html And I run :hint -- all spawn -v echo And I run :follow-hint a Then the message "Command exited successfully." should be shown From 648f89ef3147cc360222aef45a8d2d5ea1b1d910 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Sat, 21 May 2016 07:48:52 -0400 Subject: [PATCH 4/5] Implement more tests for the hinting. Validate the hint spawn fix as well as add feature tests for previously untested hinting behaviors (fill, run, --rapid). There is still no test for the 'userscript' target as running a userscript from hint mode during a test does not get the same redirection as the 'I execute the userscript ...' statement, That is, it looks in /usr/local/share/qutebrowser/userscripts rather than tests/integration/data/userscripts. --- tests/integration/features/hints.feature | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/integration/features/hints.feature b/tests/integration/features/hints.feature index 1e3001c0b..b5959fe1b 100644 --- a/tests/integration/features/hints.feature +++ b/tests/integration/features/hints.feature @@ -45,7 +45,7 @@ Feature: Using hints Then no crash should happen Scenario: Using :hint spawn with flags and -- (issue 797) - When I open data/hints/simple.html + When I open data/hints/html/simple.html And I run :hint -- all spawn -v echo And I run :follow-hint a Then the message "Command exited successfully." should be shown @@ -56,6 +56,25 @@ Feature: Using hints And I run :follow-hint a Then the message "Command exited successfully." should be shown + Scenario: Using :hint spawn with flags and --rapid (issue 797) + When I open data/hints/html/simple.html + And I run :hint --rapid all spawn -v echo + And I run :follow-hint a + Then the message "Command exited successfully." should be shown + + Scenario: Using :hint run + When I open data/hints/html/simple.html + And I run :hint all run message-info {hint-url} + And I run :follow-hint a + Then the message "http://localhost:(port)/data/hello.txt" should be shown + + Scenario: Using :hint fill + When I open data/hints/html/simple.html + And I run :hint all fill :message-info {hint-url} + And I run :follow-hint a + And I press the key "" + Then the message "http://localhost:(port)/data/hello.txt" should be shown + Scenario: Yanking to primary selection without it being supported (#1336) When selection is not supported And I run :debug-set-fake-clipboard From db09cbb96069669bb0dc9d819c43e3d665daf33d Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Tue, 24 May 2016 20:25:34 -0400 Subject: [PATCH 5/5] Implement a feature test for :hint all userscript. This adds a (testdata) substitution for 'When I run {command}' to allow providing an absolute path for the userscript. --- tests/integration/data/userscripts/echo_hint_text | 3 +++ tests/integration/features/conftest.py | 1 + tests/integration/features/hints.feature | 7 +++++++ 3 files changed, 11 insertions(+) create mode 100755 tests/integration/data/userscripts/echo_hint_text diff --git a/tests/integration/data/userscripts/echo_hint_text b/tests/integration/data/userscripts/echo_hint_text new file mode 100755 index 000000000..69b69ecff --- /dev/null +++ b/tests/integration/data/userscripts/echo_hint_text @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "message-info '$QUTE_SELECTED_TEXT'" >> "$QUTE_FIFO" diff --git a/tests/integration/features/conftest.py b/tests/integration/features/conftest.py index 9a6b1f6b7..fc6c50449 100644 --- a/tests/integration/features/conftest.py +++ b/tests/integration/features/conftest.py @@ -128,6 +128,7 @@ def run_command(quteproc, httpbin, command): else: count = None command = command.replace('(port)', str(httpbin.port)) + command = command.replace('(testdata)', utils.abs_datapath()) quteproc.send_cmd(command, count=count) diff --git a/tests/integration/features/hints.feature b/tests/integration/features/hints.feature index b5959fe1b..8c74a7d1f 100644 --- a/tests/integration/features/hints.feature +++ b/tests/integration/features/hints.feature @@ -75,6 +75,13 @@ Feature: Using hints And I press the key "" Then the message "http://localhost:(port)/data/hello.txt" should be shown + @posix + Scenario: Using :hint userscript + When I open data/hints/html/simple.html + And I run :hint all userscript (testdata)/userscripts/echo_hint_text + And I run :follow-hint a + Then the message "Follow me!" should be shown + Scenario: Yanking to primary selection without it being supported (#1336) When selection is not supported And I run :debug-set-fake-clipboard