Check for updated docs in all affected tests

Fixes #4576
This commit is contained in:
Florian Bruhin 2019-02-16 01:43:20 +01:00
parent a8910f5ef5
commit 823a0de884
4 changed files with 36 additions and 39 deletions

View File

@ -20,6 +20,7 @@
"""Steps for bdd-like tests.""" """Steps for bdd-like tests."""
import os import os
import os.path
import re import re
import sys import sys
import time import time
@ -27,11 +28,13 @@ import json
import logging import logging
import collections import collections
import textwrap import textwrap
import subprocess
import pytest import pytest
import pytest_bdd as bdd 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 qutebrowser.browser import pdfjs
from helpers import utils as testutils from helpers import utils as testutils
@ -382,6 +385,32 @@ def clear_ssl_errors(request, quteproc):
quteproc.send_cmd(':debug-clear-ssl-errors') 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 ## Then

View File

@ -24,7 +24,8 @@ Feature: Using :navigate
Then data/navigate should be loaded Then data/navigate should be loaded
Scenario: Navigating up in qute://help/ 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 And I run :navigate up
Then qute://help/ should be loaded Then qute://help/ should be loaded

View File

@ -8,7 +8,8 @@ Feature: Special qute:// pages
# :help # :help
Scenario: :help without topic 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 run :help
And I wait until qute://help/index.html is loaded And I wait until qute://help/index.html is loaded
Then the following tabs should be open: Then the following tabs should be open:
@ -39,7 +40,8 @@ Feature: Special qute:// pages
- qute://help/settings.html#editor.command (active) - qute://help/settings.html#editor.command (active)
Scenario: :help with -t 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 run :help -t
And I wait until qute://help/index.html is loaded And I wait until qute://help/index.html is loaded
Then the following tabs should be open: Then the following tabs should be open:

View File

@ -17,40 +17,5 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>. # 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 pytest_bdd as bdd
import qutebrowser
from qutebrowser.utils import docutils
bdd.scenarios('qutescheme.feature') 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])