Make ophaned editor test less flaky.
Instead of having the editor sleep a short time, explicitly send it a signal to exit.
This commit is contained in:
parent
9dfc6b0f61
commit
01a9405391
@ -116,14 +116,15 @@ Feature: Opening external editors
|
|||||||
Then the javascript message "text: foobar" should be logged
|
Then the javascript message "text: foobar" should be logged
|
||||||
|
|
||||||
Scenario: Spawning an editor and closing the tab
|
Scenario: Spawning an editor and closing the tab
|
||||||
When I set up a fake editor returning "foo" after 1s
|
When I set up a fake editor that waits
|
||||||
And I open data/editor.html
|
And I open data/editor.html
|
||||||
And I run :click-element id qute-textarea
|
And I run :click-element id qute-textarea
|
||||||
And I wait for "Entering mode KeyMode.insert (reason: clicking input)" in the log
|
And I wait for "Entering mode KeyMode.insert (reason: clicking input)" in the log
|
||||||
And I run :open-editor
|
And I run :open-editor
|
||||||
And I set tabs.last_close to blank
|
And I set tabs.last_close to blank
|
||||||
And I run :tab-close
|
And I run :tab-close
|
||||||
Then the warning "Edited element was closed" should be shown
|
And I kill the waiting editor
|
||||||
|
Then the warning "Edited element vanished" should be shown
|
||||||
|
|
||||||
@qtwebengine_todo: Caret mode is not implemented yet
|
@qtwebengine_todo: Caret mode is not implemented yet
|
||||||
Scenario: Spawning an editor in caret mode
|
Scenario: Spawning an editor in caret mode
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
import textwrap
|
import textwrap
|
||||||
|
import os
|
||||||
|
import signal
|
||||||
|
|
||||||
import pytest_bdd as bdd
|
import pytest_bdd as bdd
|
||||||
bdd.scenarios('editor.feature')
|
bdd.scenarios('editor.feature')
|
||||||
@ -66,19 +68,31 @@ def set_up_editor_empty(quteproc, server, tmpdir):
|
|||||||
set_up_editor(quteproc, server, tmpdir, "")
|
set_up_editor(quteproc, server, tmpdir, "")
|
||||||
|
|
||||||
|
|
||||||
@bdd.when(bdd.parsers.parse(
|
@bdd.when(bdd.parsers.parse('I set up a fake editor that waits'))
|
||||||
'I set up a fake editor returning "{text}" after {t}s'))
|
def set_up_editor_wait(quteproc, server, tmpdir):
|
||||||
def set_up_editor_delay(quteproc, server, tmpdir, text, t):
|
|
||||||
"""Set up editor.command to a small python script inserting a text."""
|
"""Set up editor.command to a small python script inserting a text."""
|
||||||
|
pidfile = tmpdir / 'editor_pid'
|
||||||
script = tmpdir / 'script.py'
|
script = tmpdir / 'script.py'
|
||||||
script.write(textwrap.dedent("""
|
script.write(textwrap.dedent("""
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import signal
|
||||||
|
|
||||||
time.sleep({t})
|
with open('{pidfile}', 'w') as f:
|
||||||
|
f.write(str(os.getpid()))
|
||||||
|
|
||||||
with open(sys.argv[1], 'w', encoding='utf-8') as f:
|
signal.signal(signal.SIGUSR1, lambda s, f: sys.exit(0))
|
||||||
f.write({text!r})
|
|
||||||
""".format(text=text, t=t)))
|
time.sleep(100)
|
||||||
|
""".format(pidfile=pidfile)))
|
||||||
editor = json.dumps([sys.executable, str(script), '{}'])
|
editor = json.dumps([sys.executable, str(script), '{}'])
|
||||||
quteproc.set_setting('editor.command', editor)
|
quteproc.set_setting('editor.command', editor)
|
||||||
|
|
||||||
|
|
||||||
|
@bdd.when(bdd.parsers.parse('I kill the waiting editor'))
|
||||||
|
def kill_editor_wait(quteproc, server, tmpdir):
|
||||||
|
"""Kill the waiting editor."""
|
||||||
|
pidfile = tmpdir / 'editor_pid'
|
||||||
|
pid = int(pidfile.read())
|
||||||
|
os.kill(pid, signal.SIGUSR1)
|
||||||
|
Loading…
Reference in New Issue
Block a user