From fc7105604e3937f65f173cd2cbd785a7f84b0c77 Mon Sep 17 00:00:00 2001 From: Andrii Simakov Date: Tue, 27 May 2025 14:21:57 +0300 Subject: [PATCH 1/3] Add argument support --- tests_integration/test_all.sh | 1 + tests_integration/test_with_docker.sh | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/tests_integration/test_all.sh b/tests_integration/test_all.sh index 66cf7e6bc..cbe3134eb 100755 --- a/tests_integration/test_all.sh +++ b/tests_integration/test_all.sh @@ -98,6 +98,7 @@ sh tests_integration/test_with_docker.sh \ --coverage-type "jacoco" \ --code-coverage-report-path "build/reports/jacoco/test/jacocoTestReport.csv" \ --model $MODEL \ + --max-run-time-sec 240 \ $log_db_arg \ $SUPPRESS_LOG_FILES diff --git a/tests_integration/test_with_docker.sh b/tests_integration/test_with_docker.sh index a125a410a..721761973 100755 --- a/tests_integration/test_with_docker.sh +++ b/tests_integration/test_with_docker.sh @@ -17,6 +17,7 @@ COVERAGE_TYPE="cobertura" CODE_COVERAGE_REPORT_PATH="coverage.xml" MAX_ITERATIONS=3 # Default value DESIRED_COVERAGE=70 # Default value +MAX_RUN_TIME_SEC=30 # Default value LOG_DB_PATH="${LOG_DB_PATH:-}" SUPPRESS_LOG_FILES="" @@ -46,6 +47,7 @@ while [ "$#" -gt 0 ]; do --coverage-type) COVERAGE_TYPE="$2"; shift ;; --code-coverage-report-path) CODE_COVERAGE_REPORT_PATH="$2"; shift ;; --max-iterations) MAX_ITERATIONS="$2"; shift ;; + --max-run-time-sec) MAX_RUN_TIME_SEC="$2"; shift ;; --desired-coverage) DESIRED_COVERAGE="$2"; shift ;; --log-db-path) LOG_DB_PATH="$2"; shift ;; --suppress-log-files) SUPPRESS_LOG_FILES="--suppress-log-files" ;; @@ -115,6 +117,10 @@ COMMAND="/usr/local/bin/cover-agent \ --max-iterations $MAX_ITERATIONS \ --strict-coverage" +if [ -n "$MAX_RUN_TIME_SEC" ]; then + COMMAND="$COMMAND --max-run-time-sec $MAX_RUN_TIME_SEC" +fi + if [ -n "$MODEL" ]; then COMMAND="$COMMAND --model \"$MODEL\"" fi From 34f0487a290006d1c0664d02e5b051cf22e738d2 Mon Sep 17 00:00:00 2001 From: Andrii Simakov Date: Tue, 27 May 2025 14:56:05 +0300 Subject: [PATCH 2/3] Fix iteration count in reached above message --- cover_agent/cover_agent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cover_agent/cover_agent.py b/cover_agent/cover_agent.py index f328b67ad..7a9e09b27 100644 --- a/cover_agent/cover_agent.py +++ b/cover_agent/cover_agent.py @@ -316,7 +316,7 @@ def finalize_test_generation(self, iteration_count): if self.test_validator.current_coverage >= (desired_coverage / 100): self.logger.info( f"Reached above target coverage of {desired_coverage}% " - f"(Current Coverage: {current_coverage}%) in {iteration_count} iterations." + f"(Current Coverage: {current_coverage}%) in {iteration_count + 1} iterations." ) elif iteration_count == self.config.max_iterations: coverage_type = "diff coverage" if self.config.diff_coverage else "coverage" From a14aa1647678870c3396135d3dec7f484945065c Mon Sep 17 00:00:00 2001 From: Andrii Simakov Date: Tue, 27 May 2025 17:41:41 +0300 Subject: [PATCH 3/3] Fix AICaller import in lsp_logic --- cover_agent/lsp_logic/ContextHelper.py | 2 +- templated_tests/python_fastapi/test_app.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cover_agent/lsp_logic/ContextHelper.py b/cover_agent/lsp_logic/ContextHelper.py index 36ec40f83..f56d3173c 100644 --- a/cover_agent/lsp_logic/ContextHelper.py +++ b/cover_agent/lsp_logic/ContextHelper.py @@ -2,7 +2,7 @@ from contextlib import asynccontextmanager from pathlib import Path from typing import AsyncIterator, List, Tuple, Optional -from cover_agent.AICaller import AICaller +from cover_agent.ai_caller import AICaller from cover_agent.lsp_logic.utils.utils_context import ( analyze_context, find_test_file_context, diff --git a/templated_tests/python_fastapi/test_app.py b/templated_tests/python_fastapi/test_app.py index 164d83203..c3bfc643f 100644 --- a/templated_tests/python_fastapi/test_app.py +++ b/templated_tests/python_fastapi/test_app.py @@ -13,3 +13,9 @@ def test_root(): response = client.get("/") assert response.status_code == 200 assert response.json() == {"message": "Welcome to the FastAPI application!"} + + +def test_divide_by_zero(): + response = client.get("/divide/10/0") + assert response.status_code == 400 + assert response.json() == {"detail": "Cannot divide by zero"}