Skip to content

Commit

Permalink
Add flatpak hint to :spawn message
Browse files Browse the repository at this point in the history
  • Loading branch information
The-Compiler committed Oct 30, 2021
1 parent d43529e commit ccf6243
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
10 changes: 10 additions & 0 deletions doc/changelog.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ breaking changes (such as renamed commands) can happen in minor releases.
// `Fixed` for any bug fixes.
// `Security` to invite users to upgrade in case of vulnerabilities.

[[v2.5.0]]
v2.5.0 (unreleased)
-------------------

Changed
~~~~~~~

- Improved message if a spawned process wasn't found and a Flatpak container is
in use.
[[v2.4.1]]
v2.4.1 (unreleased)
-------------------
Expand Down
6 changes: 4 additions & 2 deletions qutebrowser/misc/guiprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from PyQt5.QtCore import (pyqtSlot, pyqtSignal, QObject, QProcess,
QProcessEnvironment, QByteArray, QUrl, Qt)

from qutebrowser.utils import message, log, utils, usertypes
from qutebrowser.utils import message, log, utils, usertypes, version
from qutebrowser.api import cmdutils, apitypes
from qutebrowser.completion.models import miscmodels

Expand Down Expand Up @@ -273,7 +273,9 @@ def _on_error(self, error: QProcess.ProcessError) -> None:
known_errors = ['No such file or directory', 'Permission denied']
if (': ' in error_string and # pragma: no branch
error_string.split(': ', maxsplit=1)[1] in known_errors):
msg += f'\n(Hint: Make sure {self.cmd!r} exists and is executable)'
msg += f'\nHint: Make sure {self.cmd!r} exists and is executable'
if version.is_flatpak():
msg += ' inside the Flatpak container'

message.error(msg)

Expand Down
14 changes: 10 additions & 4 deletions tests/unit/misc/test_guiprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from PyQt5.QtCore import QProcess, QUrl

from qutebrowser.misc import guiprocess
from qutebrowser.utils import usertypes, utils
from qutebrowser.utils import usertypes, utils, version
from qutebrowser.api import cmdutils
from qutebrowser.qt import sip

Expand Down Expand Up @@ -394,8 +394,11 @@ def test_running(qtbot, proc, py_proc):
proc.outcome.was_successful()


def test_failing_to_start(qtbot, proc, caplog, message_mock):
@pytest.mark.parametrize('is_flatpak', [True, False])
def test_failing_to_start(qtbot, proc, caplog, message_mock, monkeypatch, is_flatpak):
"""Test the process failing to start."""
monkeypatch.setattr(version, 'is_flatpak', lambda: is_flatpak)

with caplog.at_level(logging.ERROR, 'message'):
with qtbot.wait_signal(proc.error, timeout=5000):
proc.start('this_does_not_exist_either', [])
Expand All @@ -405,8 +408,11 @@ def test_failing_to_start(qtbot, proc, caplog, message_mock):
"Testprocess 'this_does_not_exist_either' failed to start:")

if not utils.is_windows:
assert msg.text.endswith(
"(Hint: Make sure 'this_does_not_exist_either' exists and is executable)")
expected_msg = (
"Hint: Make sure 'this_does_not_exist_either' exists and is executable")
if is_flatpak:
expected_msg += ' inside the Flatpak container'
assert msg.text.endswith(expected_msg)

assert not proc.outcome.running
assert proc.outcome.status is None
Expand Down

0 comments on commit ccf6243

Please sign in to comment.