From ea182934f363108d71a88fd5bd20f8a55e371421 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 4 Jan 2016 20:10:03 +0100 Subject: [PATCH] Update docs for :help tests. --- tests/integration/features/misc.feature | 6 ++++-- tests/integration/features/test_misc.py | 28 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/tests/integration/features/misc.feature b/tests/integration/features/misc.feature index ea033405d..1df5d99a3 100644 --- a/tests/integration/features/misc.feature +++ b/tests/integration/features/misc.feature @@ -194,7 +194,8 @@ Feature: Various utility commands. Then the error "Invalid help topic foo!" should be shown Scenario: :help with command - When I run :tab-only + When the documentation is up to date + And I run :tab-only And I run :help :back And I wait until qute://help/commands.html#back is loaded Then the following tabs should be open: @@ -205,7 +206,8 @@ Feature: Various utility commands. Then the error "Invalid command foo!" should be shown Scenario: :help with setting - When I run :tab-only + When the documentation is up to date + And I run :tab-only And I run :help general->editor And I wait until qute://help/settings.html#general-editor is loaded Then the following tabs should be open: diff --git a/tests/integration/features/test_misc.py b/tests/integration/features/test_misc.py index 2a08aa624..62b471dc6 100644 --- a/tests/integration/features/test_misc.py +++ b/tests/integration/features/test_misc.py @@ -17,5 +17,33 @@ # 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 bdd.scenarios('misc.feature') + +import qutebrowser +from qutebrowser.utils import docutils + + +@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') + + if all(docutils.docs_up_to_date(path) for path in os.listdir(doc_path)): + return + + try: + subprocess.call(['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.call([sys.executable, update_script])