Skip to content

Commit

Permalink
check hitlog file presence
Browse files Browse the repository at this point in the history
  • Loading branch information
leondz committed Jul 23, 2024
1 parent e9a2697 commit 616c798
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/test_hitlog.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
# SPDX-FileCopyrightText: Portions Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

import contextlib
import os
import pytest

import garak
import garak.cli


CODEPATH_PREFIX = "_garak_test_hitlog_codepath"


def test_hitlog_codepath():

args = "-m test.Blank -p test.Test -d always.Fail".split()
args = f"-m test.Blank --report_prefix {CODEPATH_PREFIX} -p test.Test -d always.Fail".split()
garak.cli.main(args)
assert os.path.isfile(f"{CODEPATH_PREFIX}.hitlog.jsonl")


@pytest.fixture(scope="session", autouse=True)
def cleanup(request):
"""Cleanup a testing directory once we are finished."""

def remove_codepath_reports():
with contextlib.suppress(FileNotFoundError):
os.remove(f"{CODEPATH_PREFIX}.report.jsonl")
os.remove(f"{CODEPATH_PREFIX}.report.html")
os.remove(f"{CODEPATH_PREFIX}.hitlog.jsonl")

request.addfinalizer(remove_codepath_reports)

0 comments on commit 616c798

Please sign in to comment.