Skip to content

tests: fixed CQFD testing. #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .cqfd/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \

COPY requirements/dev.txt /tmp/dev.txt

RUN mkdir -p /cache/vulnscout && chmod -R 777 /cache

RUN pip install --no-cache-dir -r /tmp/dev.txt \
&& rm -rf /tmp/dev.txt
21 changes: 12 additions & 9 deletions tests/Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
MAKEFILE_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
SRC_DIR := $(MAKEFILE_DIR)../src
FRONTEND_DIR := $(MAKEFILE_DIR)../frontend

test: test_backend test_frontend

test_backend:
flake8 ../src
mypy --config-file tox.ini ../src
pytest --cov-report html --cov=../src
pdoc ../src -o ./htmldocs
flake8 $(SRC_DIR)
mypy --config-file tox.ini $(SRC_DIR)
pytest --cov-report html --cov=$(SRC_DIR)
pdoc $(SRC_DIR) -o ./htmldocs
find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete

test_frontend:
cd ../frontend && \
cd $(FRONTEND_DIR) && \
npm ci --include=dev && \
npm test

jenkins_test: jenkins_test_backend jenkins_test_frontend

jenkins_test_backend:
flake8
pytest --cov=src --junitxml=./junit_backend.xml
pdoc ./src -o ./htmldocs
flake8 $(SRC_DIR)
pytest --cov=$(SRC_DIR) --junitxml=./junit_backend.xml
pdoc $(SRC_DIR) -o ./htmldocs
find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete

jenkins_test_frontend:
cd frontend && \
cd $(FRONTEND_DIR) && \
npm ci --include=dev && \
npm test -- --runInBand

Expand Down
12 changes: 6 additions & 6 deletions tests/end_to_end_tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ def write_demo_files(files):
"""Write files with an real-life example issued fron cairo vulnerability."""

if "CDX_PATH" in files:
with open("tests/end_to_end_tests/input_cdx.json", "r") as f:
with open("end_to_end_tests/input_cdx.json", "r") as f:
files["CDX_PATH"].write_text(f.read())

if "SPDX_PATH" in files:
with open("tests/end_to_end_tests/input_spdx.json", "r") as f:
with open("end_to_end_tests/input_spdx.json", "r") as f:
files["SPDX_PATH"].write_text(f.read())

if "GRYPE_CDX_PATH" in files:
with open("tests/end_to_end_tests/grype_cdx.json", "r") as f:
with open("end_to_end_tests/grype_cdx.json", "r") as f:
files["GRYPE_CDX_PATH"].write_text(f.read())

if "GRYPE_SPDX_PATH" in files:
with open("tests/end_to_end_tests/grype_spdx.json", "r") as f:
with open("end_to_end_tests/grype_spdx.json", "r") as f:
files["GRYPE_SPDX_PATH"].write_text(f.read())

if "YOCTO_CVE_CHECKER" in files:
with open("tests/end_to_end_tests/yocto.json", "r") as f:
with open("end_to_end_tests/yocto.json", "r") as f:
files["YOCTO_CVE_CHECKER"].write_text(f.read())

if "TIME_ESTIMATES_PATH" in files:
with open("tests/end_to_end_tests/time_estimates.json", "r") as f:
with open("end_to_end_tests/time_estimates.json", "r") as f:
files["TIME_ESTIMATES_PATH"].write_text(f.read())

return files
2 changes: 1 addition & 1 deletion tests/spdx_merge/test_merge_spdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@pytest.fixture
def setup(tmp_path):
os.environ["INPUT_SPDX_FOLDER"] = "tests/spdx_merge/data"
os.environ["INPUT_SPDX_FOLDER"] = "spdx_merge/data"
os.environ["OUTPUT_SPDX_FILE"] = str(tmp_path / "output.spdx.json")


Expand Down