diff --git a/Makefile b/Makefile index 5c124b6..907ef4d 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,7 @@ test: ## Run tests in a Docker container test-force: ## Run tests in a Docker container while ignoring any stored state @docker volume rm codesectools_pytest-cache 2>&1 1>/dev/null || true + @docker volume rm codesectools_cstools-cache 2>&1 1>/dev/null || true @docker compose build 1>/dev/null @docker compose run --rm no-sast @docker compose run --rm with-sast diff --git a/codesectools/sasts/core/sast/__init__.py b/codesectools/sasts/core/sast/__init__.py index 30fc19f..8bce39c 100644 --- a/codesectools/sasts/core/sast/__init__.py +++ b/codesectools/sasts/core/sast/__init__.py @@ -180,7 +180,7 @@ def save_results(self, project_dir: Path, output_dir: Path, extra: dict) -> None filepath = project_dir / parent_dir / filename if filepath.is_file(): if not filepath == output_dir / filename: - filepath.rename(output_dir / filename) + shutil.move(filepath, output_dir / filename) else: if required: missing_files.append(filename) @@ -189,7 +189,7 @@ def save_results(self, project_dir: Path, output_dir: Path, extra: dict) -> None if filepaths: for filepath in filepaths: if not filepath == output_dir / filename: - filepath.rename(output_dir / filepath.name) + shutil.move(filepath, output_dir / filepath.name) else: if required: missing_files.append(filename) diff --git a/docker-compose.yml b/docker-compose.yml index a92f2d8..4dd6c5a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,7 @@ services: volumes: - pytest-cache:/app/.pytest_cache + - cstools-cache:/root/.codesectools/cache environment: _TYPER_STANDARD_TRACEBACK: 1 @@ -27,9 +28,11 @@ services: volumes: - pytest-cache:/app/.pytest_cache - + - cstools-cache:/root/.codesectools/cache + environment: _TYPER_STANDARD_TRACEBACK: 1 volumes: - pytest-cache: \ No newline at end of file + pytest-cache: + cstools-cache: \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 6b05424..4d4ac2e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "CodeSecTools" -version = "0.13.2" +version = "0.13.3" description = "A framework for code security that provides abstractions for static analysis tools and datasets to support their integration, testing, and evaluation." readme = "README.md" license = "AGPL-3.0-only" diff --git a/tests/conftest.py b/tests/conftest.py index 2c176c5..88c21c6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,11 +4,14 @@ import json import logging import os +import shutil from pathlib import Path from types import GeneratorType import pytest +from codesectools.utils import USER_CACHE_DIR + # Fix: I/O operation on closed (https://github.com/pallets/click/issues/824) logging.getLogger("matplotlib").setLevel(logging.ERROR) @@ -55,6 +58,13 @@ def pytest_sessionstart(session: pytest.Session) -> None: Skips the entire test session if no source files have changed. """ + if USER_CACHE_DIR.is_dir(): + for child in USER_CACHE_DIR.iterdir(): + if child.is_file(): + child.unlink() + elif child.is_dir(): + shutil.rmtree(child) + if not source_code_changed(): pytest.exit("No changes in source code, skipping test session.", returncode=0) diff --git a/uv.lock b/uv.lock index be22d7c..62510f1 100644 --- a/uv.lock +++ b/uv.lock @@ -221,7 +221,7 @@ wheels = [ [[package]] name = "codesectools" -version = "0.13.2" +version = "0.13.3" source = { editable = "." } dependencies = [ { name = "gitpython" },