Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@

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:
Expand Down
12 changes: 8 additions & 4 deletions utils/generate_js_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@

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:
Expand All @@ -20,15 +24,15 @@ 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'

print(f'Building {directory} ... ', end='')
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)
destination.write_bytes(searchindex.read_bytes())
print('done')