Skip to content

Commit

Permalink
Merge pull request #2008 from strictdoc-project/stanislaw/itest_cache…
Browse files Browse the repository at this point in the history
…_dir

tests/integration: make the cache folder local to a test folder
  • Loading branch information
stanislaw authored Nov 21, 2024
2 parents 443553d + ee4debc commit 91d95d0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
7 changes: 7 additions & 0 deletions strictdoc/core/project_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,14 @@ def __init__(
# Settings obtained from the strictdoc.toml config file.
self.project_title: str = project_title
self.dir_for_sdoc_assets: str = dir_for_sdoc_assets

if env_cache_dir := os.environ.get("STRICTDOC_CACHE_DIR"):
# The only use case for STRICTDOC_CACHE_DIR is to make the cache
# local to an itest folder.
assert env_cache_dir == "Output/cache", env_cache_dir
dir_for_sdoc_cache = env_cache_dir
self.dir_for_sdoc_cache: str = dir_for_sdoc_cache

self.project_features: List[str] = project_features
self.server_host: str = server_host
self.server_port: int = server_port
Expand Down
7 changes: 6 additions & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import re
import sys
from enum import Enum
from typing import Optional
from typing import Optional, Dict

if not hasattr(inspect, "getargspec"):
inspect.getargspec = inspect.getfullargspec
Expand Down Expand Up @@ -58,17 +58,21 @@ def run_invoke_with_tox(
context,
environment_type: ToxEnvironment,
command: str,
environment: Optional[Dict] = None,
) -> invoke.runners.Result:
assert isinstance(environment_type, ToxEnvironment)
assert isinstance(command, str)

tox_py_version = f"py{sys.version_info.major}{sys.version_info.minor}"

return run_invoke(
context,
f"""
tox
-e {tox_py_version}-{environment_type.value} --
{command}
""",
environment=environment,
)


Expand Down Expand Up @@ -369,6 +373,7 @@ def test_integration(
context,
environment,
itest_command,
environment={"STRICTDOC_CACHE_DIR": "Output/cache"},
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN: %strictdoc export %S --output-dir Output | filecheck %s --dump-input=fail
CHECK: Compile Jinja templates {{.*}}s
CHECK: Published: Hello world doc

RUN: rm -rf Output/
RUN: rm -rf Output/html

RUN: %strictdoc export %S --output-dir Output | filecheck %s --dump-input=fail --check-prefix=CHECK-SECOND
CHECK-SECOND-NOT: Compile Jinja templates {{.*}}s
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ if "TEST_HTML2PDF" in lit_config.params:
chromedriver = lit_config.params['CHROMEDRIVER']
config.substitutions.append(('%chromedriver', chromedriver))
config.available_features.add('SYSTEM_CHROMEDRIVER')

if (env_cache_dir := os.getenv('STRICTDOC_CACHE_DIR', None)) is not None:
config.environment['STRICTDOC_CACHE_DIR'] = env_cache_dir
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ deps =
-rrequirements.check.txt
pass_env=
CHROMEWEBDRIVER
STRICTDOC_CACHE_DIR
commands =
python developer/pip_install_strictdoc_deps.py
{posargs}
Expand Down

0 comments on commit 91d95d0

Please sign in to comment.