diff --git a/tests/end2end/features/conftest.py b/tests/end2end/features/conftest.py index ca14768ef..3e0e82456 100644 --- a/tests/end2end/features/conftest.py +++ b/tests/end2end/features/conftest.py @@ -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 diff --git a/tests/end2end/features/navigate.feature b/tests/end2end/features/navigate.feature index 07bd56c69..2596f3ef1 100644 --- a/tests/end2end/features/navigate.feature +++ b/tests/end2end/features/navigate.feature @@ -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 diff --git a/tests/end2end/features/qutescheme.feature b/tests/end2end/features/qutescheme.feature index 0f5954e19..fd41515a5 100644 --- a/tests/end2end/features/qutescheme.feature +++ b/tests/end2end/features/qutescheme.feature @@ -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: diff --git a/tests/end2end/features/test_qutescheme_bdd.py b/tests/end2end/features/test_qutescheme_bdd.py index 8706a1a9c..2245143f7 100644 --- a/tests/end2end/features/test_qutescheme_bdd.py +++ b/tests/end2end/features/test_qutescheme_bdd.py @@ -17,40 +17,5 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . -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])