Skip to content

Commit 91d95d0

Browse files
authored
Merge pull request #2008 from strictdoc-project/stanislaw/itest_cache_dir
tests/integration: make the cache folder local to a test folder
2 parents 443553d + ee4debc commit 91d95d0

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

strictdoc/core/project_config.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,14 @@ def __init__(
111111
# Settings obtained from the strictdoc.toml config file.
112112
self.project_title: str = project_title
113113
self.dir_for_sdoc_assets: str = dir_for_sdoc_assets
114+
115+
if env_cache_dir := os.environ.get("STRICTDOC_CACHE_DIR"):
116+
# The only use case for STRICTDOC_CACHE_DIR is to make the cache
117+
# local to an itest folder.
118+
assert env_cache_dir == "Output/cache", env_cache_dir
119+
dir_for_sdoc_cache = env_cache_dir
114120
self.dir_for_sdoc_cache: str = dir_for_sdoc_cache
121+
115122
self.project_features: List[str] = project_features
116123
self.server_host: str = server_host
117124
self.server_port: int = server_port

tasks.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import re
66
import sys
77
from enum import Enum
8-
from typing import Optional
8+
from typing import Optional, Dict
99

1010
if not hasattr(inspect, "getargspec"):
1111
inspect.getargspec = inspect.getfullargspec
@@ -58,17 +58,21 @@ def run_invoke_with_tox(
5858
context,
5959
environment_type: ToxEnvironment,
6060
command: str,
61+
environment: Optional[Dict] = None,
6162
) -> invoke.runners.Result:
6263
assert isinstance(environment_type, ToxEnvironment)
6364
assert isinstance(command, str)
65+
6466
tox_py_version = f"py{sys.version_info.major}{sys.version_info.minor}"
67+
6568
return run_invoke(
6669
context,
6770
f"""
6871
tox
6972
-e {tox_py_version}-{environment_type.value} --
7073
{command}
7174
""",
75+
environment=environment,
7276
)
7377

7478

@@ -369,6 +373,7 @@ def test_integration(
369373
context,
370374
environment,
371375
itest_command,
376+
environment={"STRICTDOC_CACHE_DIR": "Output/cache"},
372377
)
373378

374379

tests/integration/commands/export/html/precompiled_jinja_templates/01_basic/test.itest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN: %strictdoc export %S --output-dir Output | filecheck %s --dump-input=fail
66
CHECK: Compile Jinja templates {{.*}}s
77
CHECK: Published: Hello world doc
88

9-
RUN: rm -rf Output/
9+
RUN: rm -rf Output/html
1010

1111
RUN: %strictdoc export %S --output-dir Output | filecheck %s --dump-input=fail --check-prefix=CHECK-SECOND
1212
CHECK-SECOND-NOT: Compile Jinja templates {{.*}}s

tests/integration/lit.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ if "TEST_HTML2PDF" in lit_config.params:
4747
chromedriver = lit_config.params['CHROMEDRIVER']
4848
config.substitutions.append(('%chromedriver', chromedriver))
4949
config.available_features.add('SYSTEM_CHROMEDRIVER')
50+
51+
if (env_cache_dir := os.getenv('STRICTDOC_CACHE_DIR', None)) is not None:
52+
config.environment['STRICTDOC_CACHE_DIR'] = env_cache_dir

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ deps =
2929
-rrequirements.check.txt
3030
pass_env=
3131
CHROMEWEBDRIVER
32+
STRICTDOC_CACHE_DIR
3233
commands =
3334
python developer/pip_install_strictdoc_deps.py
3435
{posargs}

0 commit comments

Comments
 (0)