Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Commit a31d50b

Browse files
committed
Added improved coverage scripts for tools modules
1 parent 5fd6c14 commit a31d50b

6 files changed

Lines changed: 156 additions & 0 deletions

.coveragerc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
[run]
22
source = src.cli_code
3+
include =
4+
*/src/cli_code/tools/test_runner.py
5+
*/src/cli_code/models/gemini.py
36
omit =
47
*/.rules/*
58
*/.venv/*

focused_test_runner_coverage.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
# focused_test_runner_coverage.sh - Run targeted coverage for test_runner.py
3+
4+
set -e
5+
6+
echo "Running targeted test_runner.py coverage..."
7+
8+
# Clean any existing coverage data
9+
coverage erase
10+
11+
# Run only the tests from tests/tools with direct imports
12+
echo "Running tests with direct imports..."
13+
python -m pytest tests/tools/test_test_runner_tool.py -v --cov=src.cli_code.tools.test_runner
14+
15+
# Generate HTML report
16+
coverage html
17+
18+
echo "Coverage complete. Check coverage_html/index.html for detailed report."

run_specific_coverage.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
# run_specific_coverage.sh - Run comprehensive coverage for a specific module
3+
4+
# Set error handling
5+
set -e
6+
7+
MODULE=$1
8+
MODULE_PATH=$2
9+
10+
if [ -z "$MODULE" ] || [ -z "$MODULE_PATH" ]; then
11+
echo "Usage: $0 module_name module_path"
12+
echo "Example: $0 test_runner src/cli_code/tools/test_runner.py"
13+
exit 1
14+
fi
15+
16+
echo "Running comprehensive coverage for $MODULE..."
17+
18+
# Clear existing coverage data
19+
coverage erase
20+
21+
# Find all test files that might test this module
22+
TEST_FILES=$(find tests test_dir -name "test_*.py" -type f -exec grep -l "$MODULE" {} \;)
23+
24+
if [ -z "$TEST_FILES" ]; then
25+
echo "No test files found for $MODULE"
26+
exit 1
27+
fi
28+
29+
echo "Found test files:"
30+
echo "$TEST_FILES"
31+
32+
# Run each test file
33+
for TEST_FILE in $TEST_FILES; do
34+
echo "=== Running $TEST_FILE ==="
35+
MODULE_DOT_PATH=$(echo "$MODULE_PATH" | sed 's/\//./' | sed 's/\.py$//')
36+
if [[ "$MODULE_DOT_PATH" != src.* ]]; then
37+
MODULE_DOT_PATH="src.$MODULE_DOT_PATH"
38+
fi
39+
python -m pytest "$TEST_FILE" -v --cov="$MODULE_DOT_PATH" --cov-append
40+
done
41+
42+
# Generate detailed report
43+
echo "=== Generating coverage report ==="
44+
coverage report --include="$MODULE_PATH"
45+
coverage html --include="$MODULE_PATH"
46+
47+
echo "Coverage analysis complete for $MODULE"

run_targeted_coverage.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@ set -e
66

77
echo "Running coverage for key modules..."
88

9+
# Clear existing coverage data first to avoid mixed results
10+
coverage erase
11+
912
# Test runner tool - Run test files separately to avoid import conflicts
1013
echo "==== Testing test_runner.py (test_dir tests) ===="
1114
python -m pytest test_dir/test_test_runner_tool.py -v --cov=src.cli_code.tools.test_runner --cov-report=term
1215

1316
echo "==== Testing test_runner.py (tests/tools tests) ===="
1417
python -m pytest tests/tools/test_test_runner_tool.py -v --cov=src.cli_code.tools.test_runner --cov-append --cov-report=term
1518

19+
# Add test_runner coverage to main report
20+
coverage combine
21+
1622
# Gemini model
1723
echo "==== Testing gemini.py ===="
1824
python -m pytest test_dir/test_gemini_model*.py -v --cov=src.cli_code.models.gemini --cov-report=term
@@ -39,4 +45,9 @@ python -m pytest tests/tools/test_task_complete_tool.py -v --cov=src.cli_code.to
3945
echo "==== Testing other tools ===="
4046
python -m pytest test_dir/test_tools_basic.py test_dir/test_tools_init_coverage.py test_dir/test_directory_tools.py test_dir/test_quality_tools.py test_dir/test_summarizer_tool.py -v --cov=src.cli_code.tools --cov-report=term
4147

48+
# Generate a complete coverage report at the end
49+
coverage combine
50+
coverage report
51+
coverage html
52+
4253
echo "Targeted coverage complete!"

test_runner_coverage.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
# test_runner_coverage.sh - Run detailed coverage for test_runner.py
3+
4+
# Set error handling
5+
set -e
6+
7+
echo "Running detailed coverage for test_runner.py..."
8+
9+
# Clear existing coverage data
10+
coverage erase
11+
12+
# Run all test_runner.py tests with coverage
13+
echo "=== Running tests/tools/test_test_runner_tool.py ==="
14+
python -m pytest tests/tools/test_test_runner_tool.py -v --cov=src.cli_code.tools.test_runner --cov-report=term
15+
16+
echo "=== Running test_dir/test_test_runner_tool.py ==="
17+
python -m pytest test_dir/test_test_runner_tool.py -v --cov=src.cli_code.tools.test_runner --cov-append --cov-report=term
18+
19+
# Combine coverage data and generate reports
20+
echo "=== Generating combined coverage report ==="
21+
coverage combine
22+
coverage report --include="src/cli_code/tools/test_runner.py"
23+
coverage html --include="src/cli_code/tools/test_runner.py"
24+
25+
echo "Test runner coverage complete!"

tools_coverage.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
# tools_coverage.sh - Run comprehensive coverage for all tool modules
3+
4+
set -e
5+
6+
echo "Running comprehensive tools coverage..."
7+
8+
# Clean any existing coverage data
9+
coverage erase
10+
11+
# Test runner tool
12+
echo "=== Running test_runner.py tests ==="
13+
python -m pytest tests/tools/test_test_runner_tool.py -v --cov=src.cli_code.tools.test_runner
14+
15+
# Task complete tool
16+
echo "=== Running task_complete_tool.py tests ==="
17+
python -m pytest tests/tools/test_task_complete_tool.py -v --cov=src.cli_code.tools.task_complete_tool --cov-append
18+
19+
# File tools
20+
echo "=== Running file_tools.py tests ==="
21+
python -m pytest test_dir/test_file_tools.py -v --cov=src.cli_code.tools.file_tools --cov-append
22+
23+
# Directory tools
24+
echo "=== Running directory_tools.py tests ==="
25+
python -m pytest test_dir/test_directory_tools.py -v --cov=src.cli_code.tools.directory_tools --cov-append
26+
27+
# Quality tools
28+
echo "=== Running quality_tools.py tests ==="
29+
python -m pytest test_dir/test_quality_tools.py -v --cov=src.cli_code.tools.quality_tools --cov-append
30+
31+
# Summarizer tool
32+
echo "=== Running summarizer_tool.py tests ==="
33+
python -m pytest test_dir/test_summarizer_tool.py -v --cov=src.cli_code.tools.summarizer_tool --cov-append
34+
35+
# Tree tool
36+
echo "=== Running tree_tool.py tests ==="
37+
python -m pytest test_dir/test_tree_tool.py test_dir/test_tree_tool_edge_cases.py -v --cov=src.cli_code.tools.tree_tool --cov-append
38+
39+
# System tools
40+
echo "=== Running system_tools.py tests ==="
41+
python -m pytest test_dir/test_tools_basic.py -v --cov=src.cli_code.tools.system_tools --cov-append
42+
43+
# Base tool class
44+
echo "=== Running base.py tests ==="
45+
python -m pytest test_dir/test_tools_init_coverage.py -v --cov=src.cli_code.tools.base --cov-append
46+
47+
# Generate comprehensive report
48+
echo "=== Generating comprehensive coverage report ==="
49+
coverage report --include="src/cli_code/tools/*.py"
50+
coverage html
51+
52+
echo "Tools coverage complete. Check coverage_html/index.html for detailed report."

0 commit comments

Comments
 (0)