Skip to content

Commit 99825b1

Browse files
authored
Merge pull request #20 from OPPIDA/tests/cache-downloads
2 parents 980f852 + 24095ad commit 99825b1

6 files changed

Lines changed: 20 additions & 6 deletions

File tree

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ test: ## Run tests in a Docker container
2222

2323
test-force: ## Run tests in a Docker container while ignoring any stored state
2424
@docker volume rm codesectools_pytest-cache 2>&1 1>/dev/null || true
25+
@docker volume rm codesectools_cstools-cache 2>&1 1>/dev/null || true
2526
@docker compose build 1>/dev/null
2627
@docker compose run --rm no-sast
2728
@docker compose run --rm with-sast

codesectools/sasts/core/sast/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def save_results(self, project_dir: Path, output_dir: Path, extra: dict) -> None
180180
filepath = project_dir / parent_dir / filename
181181
if filepath.is_file():
182182
if not filepath == output_dir / filename:
183-
filepath.rename(output_dir / filename)
183+
shutil.move(filepath, output_dir / filename)
184184
else:
185185
if required:
186186
missing_files.append(filename)
@@ -189,7 +189,7 @@ def save_results(self, project_dir: Path, output_dir: Path, extra: dict) -> None
189189
if filepaths:
190190
for filepath in filepaths:
191191
if not filepath == output_dir / filename:
192-
filepath.rename(output_dir / filepath.name)
192+
shutil.move(filepath, output_dir / filepath.name)
193193
else:
194194
if required:
195195
missing_files.append(filename)

docker-compose.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ services:
1111

1212
volumes:
1313
- pytest-cache:/app/.pytest_cache
14+
- cstools-cache:/root/.codesectools/cache
1415

1516
environment:
1617
_TYPER_STANDARD_TRACEBACK: 1
@@ -27,9 +28,11 @@ services:
2728

2829
volumes:
2930
- pytest-cache:/app/.pytest_cache
30-
31+
- cstools-cache:/root/.codesectools/cache
32+
3133
environment:
3234
_TYPER_STANDARD_TRACEBACK: 1
3335

3436
volumes:
35-
pytest-cache:
37+
pytest-cache:
38+
cstools-cache:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "CodeSecTools"
3-
version = "0.13.2"
3+
version = "0.13.3"
44
description = "A framework for code security that provides abstractions for static analysis tools and datasets to support their integration, testing, and evaluation."
55
readme = "README.md"
66
license = "AGPL-3.0-only"

tests/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
import json
55
import logging
66
import os
7+
import shutil
78
from pathlib import Path
89
from types import GeneratorType
910

1011
import pytest
1112

13+
from codesectools.utils import USER_CACHE_DIR
14+
1215
# Fix: I/O operation on closed (https://github.com/pallets/click/issues/824)
1316
logging.getLogger("matplotlib").setLevel(logging.ERROR)
1417

@@ -55,6 +58,13 @@ def pytest_sessionstart(session: pytest.Session) -> None:
5558
5659
Skips the entire test session if no source files have changed.
5760
"""
61+
if USER_CACHE_DIR.is_dir():
62+
for child in USER_CACHE_DIR.iterdir():
63+
if child.is_file():
64+
child.unlink()
65+
elif child.is_dir():
66+
shutil.rmtree(child)
67+
5868
if not source_code_changed():
5969
pytest.exit("No changes in source code, skipping test session.", returncode=0)
6070

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)