Improve JavaScript test fixture generation (#12531)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This commit is contained in:
James Addison 2024-07-10 19:00:34 +01:00 committed by GitHub
parent 6e3a191185
commit 84c11b2f66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 5 deletions

View File

@ -13,7 +13,11 @@ from sphinx.search import IndexBuilder
from tests.utils import TESTS_ROOT
JAVASCRIPT_TEST_ROOTS = list((TESTS_ROOT / 'js' / 'roots').iterdir())
JAVASCRIPT_TEST_ROOTS = [
directory
for directory in (TESTS_ROOT / 'js' / 'roots').iterdir()
if (directory / 'conf.py').exists()
]
class DummyEnvironment:

View File

@ -1,11 +1,16 @@
#!/usr/bin/env python3
import shutil
import subprocess
from pathlib import Path
SPHINX_ROOT = Path(__file__).resolve().parent.parent
TEST_JS_FIXTURES = SPHINX_ROOT / 'tests' / 'js' / 'fixtures'
TEST_JS_ROOTS = SPHINX_ROOT / 'tests' / 'js' / 'roots'
TEST_JS_ROOTS = [
directory
for directory in (SPHINX_ROOT / 'tests' / 'js' / 'roots').iterdir()
if (directory / 'conf.py').exists()
]
def build(srcdir: Path) -> None:
@ -20,7 +25,7 @@ def build(srcdir: Path) -> None:
subprocess.run(cmd, check=True, capture_output=True)
for directory in TEST_JS_ROOTS.iterdir():
for directory in TEST_JS_ROOTS:
searchindex = directory / '_build' / 'searchindex.js'
destination = TEST_JS_FIXTURES / directory.name / 'searchindex.js'
@ -28,7 +33,7 @@ for directory in TEST_JS_ROOTS.iterdir():
build(directory)
print('done')
print(f'Moving {searchindex} to {destination} ... ', end='')
print(f'Copying {searchindex} to {destination} ... ', end='')
destination.parent.mkdir(exist_ok=True)
searchindex.replace(destination)
shutil.copy2(searchindex, destination)
print('done')