mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Improve JavaScript test fixture generation (#12531)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This commit is contained in:
parent
6e3a191185
commit
84c11b2f66
@ -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:
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user