parent
a8910f5ef5
commit
823a0de884
@ -20,6 +20,7 @@
|
||||
"""Steps for bdd-like tests."""
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
@ -27,11 +28,13 @@ import json
|
||||
import logging
|
||||
import collections
|
||||
import textwrap
|
||||
import subprocess
|
||||
|
||||
import pytest
|
||||
import pytest_bdd as bdd
|
||||
|
||||
from qutebrowser.utils import log, utils
|
||||
import qutebrowser
|
||||
from qutebrowser.utils import log, utils, docutils
|
||||
from qutebrowser.browser import pdfjs
|
||||
from helpers import utils as testutils
|
||||
|
||||
@ -382,6 +385,32 @@ def clear_ssl_errors(request, quteproc):
|
||||
quteproc.send_cmd(':debug-clear-ssl-errors')
|
||||
|
||||
|
||||
@bdd.when("the documentation is up to date")
|
||||
def update_documentation():
|
||||
"""Update the docs before testing :help."""
|
||||
base_path = os.path.dirname(os.path.abspath(qutebrowser.__file__))
|
||||
doc_path = os.path.join(base_path, 'html', 'doc')
|
||||
script_path = os.path.join(base_path, '..', 'scripts')
|
||||
|
||||
try:
|
||||
os.mkdir(doc_path)
|
||||
except FileExistsError:
|
||||
pass
|
||||
|
||||
files = os.listdir(doc_path)
|
||||
if files and all(docutils.docs_up_to_date(p) for p in files):
|
||||
return
|
||||
|
||||
try:
|
||||
subprocess.run(['asciidoc'], stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL)
|
||||
except OSError:
|
||||
pytest.skip("Docs outdated and asciidoc unavailable!")
|
||||
|
||||
update_script = os.path.join(script_path, 'asciidoc2html.py')
|
||||
subprocess.run([sys.executable, update_script])
|
||||
|
||||
|
||||
## Then
|
||||
|
||||
|
||||
|
@ -24,7 +24,8 @@ Feature: Using :navigate
|
||||
Then data/navigate should be loaded
|
||||
|
||||
Scenario: Navigating up in qute://help/
|
||||
When I open qute://help/commands.html
|
||||
When the documentation is up to date
|
||||
And I open qute://help/commands.html
|
||||
And I run :navigate up
|
||||
Then qute://help/ should be loaded
|
||||
|
||||
|
@ -8,7 +8,8 @@ Feature: Special qute:// pages
|
||||
# :help
|
||||
|
||||
Scenario: :help without topic
|
||||
When I run :tab-only
|
||||
When the documentation is up to date
|
||||
And I run :tab-only
|
||||
And I run :help
|
||||
And I wait until qute://help/index.html is loaded
|
||||
Then the following tabs should be open:
|
||||
@ -39,7 +40,8 @@ Feature: Special qute:// pages
|
||||
- qute://help/settings.html#editor.command (active)
|
||||
|
||||
Scenario: :help with -t
|
||||
When I run :tab-only
|
||||
When the documentation is up to date
|
||||
And I run :tab-only
|
||||
And I run :help -t
|
||||
And I wait until qute://help/index.html is loaded
|
||||
Then the following tabs should be open:
|
||||
|
@ -17,40 +17,5 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import sys
|
||||
import os.path
|
||||
import subprocess
|
||||
|
||||
import pytest
|
||||
import pytest_bdd as bdd
|
||||
|
||||
import qutebrowser
|
||||
from qutebrowser.utils import docutils
|
||||
|
||||
bdd.scenarios('qutescheme.feature')
|
||||
|
||||
|
||||
@bdd.when("the documentation is up to date")
|
||||
def update_documentation():
|
||||
"""Update the docs before testing :help."""
|
||||
base_path = os.path.dirname(os.path.abspath(qutebrowser.__file__))
|
||||
doc_path = os.path.join(base_path, 'html', 'doc')
|
||||
script_path = os.path.join(base_path, '..', 'scripts')
|
||||
|
||||
try:
|
||||
os.mkdir(doc_path)
|
||||
except FileExistsError:
|
||||
pass
|
||||
|
||||
files = os.listdir(doc_path)
|
||||
if files and all(docutils.docs_up_to_date(p) for p in files):
|
||||
return
|
||||
|
||||
try:
|
||||
subprocess.run(['asciidoc'], stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL)
|
||||
except OSError:
|
||||
pytest.skip("Docs outdated and asciidoc unavailable!")
|
||||
|
||||
update_script = os.path.join(script_path, 'asciidoc2html.py')
|
||||
subprocess.run([sys.executable, update_script])
|
||||
|
Loading…
Reference in New Issue
Block a user