Add a test for :restart
This commit is contained in:
parent
f8685230a5
commit
7bf5abbc69
|
|
@ -196,6 +196,7 @@ Fixed
|
|||
- The `asciidoc2html.py` script now correctly uses the virtualenv-installed
|
||||
asciidoc rather than requiring a system-wide installation.
|
||||
- "Package would be ignored" deprecation warnings when running `setup.py`.
|
||||
- ResourceWarning when using `:restart`.
|
||||
- Crash when shutting down before fully initialized.
|
||||
- Crash with some notification servers when the server is quitting.
|
||||
- Crash when using QtWebKit with PAC and the file has an invalid encoding.
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import shutil
|
|||
import argparse
|
||||
import tokenize
|
||||
import functools
|
||||
import warnings
|
||||
import subprocess
|
||||
from typing import Iterable, Mapping, MutableSequence, Sequence, cast
|
||||
|
||||
|
|
@ -179,11 +180,18 @@ class Quitter(QObject):
|
|||
# Open a new process and immediately shutdown the existing one
|
||||
try:
|
||||
args = self._get_restart_args(pages, session, override_args)
|
||||
subprocess.Popen(args) # pylint: disable=consider-using-with
|
||||
proc = subprocess.Popen(args) # pylint: disable=consider-using-with
|
||||
except OSError:
|
||||
log.destroy.exception("Failed to restart")
|
||||
return False
|
||||
else:
|
||||
log.destroy.debug(f"New process PID: {proc.pid}")
|
||||
# Avoid ResourceWarning about still running subprocess when quitting.
|
||||
warnings.filterwarnings(
|
||||
"ignore",
|
||||
category=ResourceWarning,
|
||||
message=f"subprocess {proc.pid} is still running",
|
||||
)
|
||||
return True
|
||||
|
||||
def shutdown(self, status: int = 0,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
"""Test starting qutebrowser with special arguments/environments."""
|
||||
|
||||
import os
|
||||
import signal
|
||||
import configparser
|
||||
import subprocess
|
||||
import sys
|
||||
|
|
@ -916,3 +918,25 @@ def test_logfilter_arg_does_not_crash(request, quteproc_new):
|
|||
# Waiting for quit to make sure no other warning is emitted
|
||||
quteproc_new.send_cmd(':quit')
|
||||
quteproc_new.wait_for_quit()
|
||||
|
||||
|
||||
def test_restart(request, quteproc_new):
|
||||
args = _base_args(request.config) + ['--temp-basedir']
|
||||
quteproc_new.start(args)
|
||||
quteproc_new.send_cmd(':restart')
|
||||
|
||||
prefix = "New process PID: "
|
||||
line = quteproc_new.wait_for(message=f"{prefix}*")
|
||||
quteproc_new.wait_for_quit()
|
||||
|
||||
assert line.message.startswith(prefix)
|
||||
pid = int(line.message[len(prefix):])
|
||||
os.kill(pid, signal.SIGTERM)
|
||||
|
||||
try:
|
||||
# If the new process hangs, this will hang too.
|
||||
# Still better than just ignoring it, so we can fix it if something is broken.
|
||||
os.waitpid(pid, 0) # pid, options... positional-only :(
|
||||
except ChildProcessError:
|
||||
# Already gone
|
||||
pass
|
||||
|
|
|
|||
Loading…
Reference in New Issue