-
Notifications
You must be signed in to change notification settings - Fork 0
Fix testing regression #10
Changes from 2 commits
e84589e
8dfbaa8
19e9e13
03dd001
a1af2eb
03e6569
f036972
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,74 @@ | ||||||
| #!/bin/bash | ||||||
|
|
||||||
| # Script to find hanging tests | ||||||
| echo "Running tests individually to find hanging tests..." | ||||||
|
|
||||||
| # Clean up cache files first | ||||||
| find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true | ||||||
| find . -name "*.pyc" -exec rm -f {} + 2>/dev/null || true | ||||||
|
|
||||||
| # Set timeout (in seconds) | ||||||
| TIMEOUT=15 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider making the timeout configurable via an environment variable. This would allow users to adjust the timeout based on their specific needs and hardware. Also, consider adding a comment about the units of the timeout value (seconds).
Suggested change
|
||||||
|
|
||||||
| # Function to run a single test with timeout | ||||||
| run_test_with_timeout() { | ||||||
| TEST_FILE=$1 | ||||||
| echo "Testing: $TEST_FILE" | ||||||
| if timeout $TIMEOUT python -m pytest "$TEST_FILE" -v; then | ||||||
| echo "✅ $TEST_FILE completed successfully" | ||||||
| else | ||||||
| EXIT_CODE=$? | ||||||
| if [ $EXIT_CODE -eq 124 ]; then | ||||||
| echo "❌ $TEST_FILE TIMEOUT - Test is hanging!" | ||||||
| else | ||||||
| echo "❌ $TEST_FILE failed with exit code $EXIT_CODE" | ||||||
| fi | ||||||
| fi | ||||||
| echo "----------------------------------------" | ||||||
| } | ||||||
|
|
||||||
| # Test files to check - base list from most critical files | ||||||
| TEST_FILES=( | ||||||
| "test_dir/test_file_tools.py" | ||||||
| "test_dir/test_system_tools.py" | ||||||
| "test_dir/test_directory_tools.py" | ||||||
| "test_dir/improved/test_quality_tools.py" | ||||||
| "test_dir/improved/test_summarizer_tool.py" | ||||||
| "test_dir/improved/test_tree_tool.py" | ||||||
| "test_dir/test_models_base.py" | ||||||
| "test_dir/test_model_basic.py" | ||||||
| "test_dir/test_model_integration.py" | ||||||
| "test_dir/test_gemini_model.py" | ||||||
| "test_dir/test_gemini_model_advanced.py" | ||||||
| "test_dir/test_gemini_model_coverage.py" | ||||||
| "test_dir/test_gemini_model_error_handling.py" | ||||||
| "test_dir/test_ollama_model.py" | ||||||
| "test_dir/test_ollama_model_advanced.py" | ||||||
| "test_dir/test_ollama_model_coverage.py" | ||||||
| "test_dir/test_ollama_model_context.py" | ||||||
| "test_dir/test_ollama_model_error_handling.py" | ||||||
| "test_dir/test_config.py" | ||||||
| "test_dir/test_config_comprehensive.py" | ||||||
| "test_dir/test_config_edge_cases.py" | ||||||
| "test_dir/test_config_missing_methods.py" | ||||||
| "test_dir/test_main.py" | ||||||
| "test_dir/test_main_comprehensive.py" | ||||||
| "test_dir/test_main_edge_cases.py" | ||||||
| "test_dir/test_main_improved.py" | ||||||
| "test_dir/test_task_complete_tool.py" | ||||||
| "test_dir/test_tools_base.py" | ||||||
| "test_dir/test_tools_init_coverage.py" | ||||||
| "test_dir/test_utils.py" | ||||||
| "test_dir/test_utils_comprehensive.py" | ||||||
| "test_dir/test_test_runner_tool.py" | ||||||
| "test_dir/test_basic_functions.py" | ||||||
| "test_dir/test_tools_basic.py" | ||||||
| "test_dir/test_tree_tool_edge_cases.py" | ||||||
| ) | ||||||
|
ipv1337 marked this conversation as resolved.
Outdated
|
||||||
|
|
||||||
| # Run each test file individually | ||||||
| for TEST_FILE in "${TEST_FILES[@]}"; do | ||||||
| run_test_with_timeout "$TEST_FILE" | ||||||
| done | ||||||
|
|
||||||
| echo "Test scan complete. Check output for any hanging tests." | ||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,22 +1,131 @@ | ||||||
| #!/bin/bash | ||||||
| # Script to generate coverage for CI pipeline | ||||||
| # Script to generate coverage for CI pipeline with timeouts to prevent hanging | ||||||
|
|
||||||
| set -e # Exit on error | ||||||
| set -x # Print commands for debugging | ||||||
|
|
||||||
| echo "Starting coverage generation for CI..." | ||||||
|
|
||||||
| # Set up coverage directory | ||||||
| mkdir -p coverage_html | ||||||
|
|
||||||
| # Run pytest with coverage enabled and generate reports | ||||||
| # Clean up any pycache files to avoid import conflicts | ||||||
| find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true | ||||||
| find . -name "*.pyc" -delete | ||||||
|
|
||||||
| # Run tests in smaller batches with timeouts | ||||||
| echo "Running test suite with coverage enabled..." | ||||||
|
|
||||||
| # First, run the basic tools tests which are known to work | ||||||
| echo "Running tools tests (known to work well)..." | ||||||
| python -m pytest \ | ||||||
| --cov=src.cli_code \ | ||||||
| --cov-report=xml:coverage.xml \ | ||||||
| --cov-report=html:coverage_html \ | ||||||
| --cov-report=term \ | ||||||
| test_dir/test_file_tools.py test_dir/test_directory_tools.py test_dir/test_system_tools.py \ | ||||||
| test_dir/improved/test_quality_tools.py test_dir/improved/test_summarizer_tool.py test_dir/improved/test_tree_tool.py | ||||||
| --timeout=60 \ | ||||||
| test_dir/test_file_tools.py \ | ||||||
| test_dir/test_system_tools.py \ | ||||||
| test_dir/test_directory_tools.py \ | ||||||
| test_dir/improved/test_quality_tools.py \ | ||||||
| test_dir/improved/test_summarizer_tool.py \ | ||||||
| test_dir/improved/test_tree_tool.py | ||||||
|
|
||||||
| # Now run the model tests separately | ||||||
| echo "Running model tests..." | ||||||
| python -m pytest \ | ||||||
| --cov=src.cli_code \ | ||||||
| --cov-append \ | ||||||
| --cov-report=xml:coverage.xml \ | ||||||
| --cov-report=html:coverage_html \ | ||||||
| --cov-report=term \ | ||||||
| --timeout=60 \ | ||||||
| test_dir/test_models_base.py \ | ||||||
| test_dir/test_model_basic.py \ | ||||||
| test_dir/test_model_integration.py | ||||||
|
|
||||||
| # Run gemini model tests individually | ||||||
| for test_file in \ | ||||||
| test_dir/test_gemini_model.py \ | ||||||
| test_dir/test_gemini_model_advanced.py \ | ||||||
| test_dir/test_gemini_model_coverage.py \ | ||||||
| test_dir/test_gemini_model_error_handling.py; do | ||||||
| echo "Running $test_file with timeout..." | ||||||
| python -m pytest \ | ||||||
| --cov=src.cli_code \ | ||||||
| --cov-append \ | ||||||
| --timeout=60 \ | ||||||
| "$test_file" || echo "Warning: $test_file timed out or failed" | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Suggested change
|
||||||
| done | ||||||
|
|
||||||
| # Run ollama model tests individually | ||||||
| for test_file in \ | ||||||
| test_dir/test_ollama_model.py \ | ||||||
| test_dir/test_ollama_model_advanced.py \ | ||||||
| test_dir/test_ollama_model_coverage.py \ | ||||||
| test_dir/test_ollama_model_context.py \ | ||||||
| test_dir/test_ollama_model_error_handling.py; do | ||||||
| echo "Running $test_file with timeout..." | ||||||
| python -m pytest \ | ||||||
| --cov=src.cli_code \ | ||||||
| --cov-append \ | ||||||
| --timeout=60 \ | ||||||
| "$test_file" || echo "Warning: $test_file timed out or failed" | ||||||
| done | ||||||
|
|
||||||
| # Run config tests individually | ||||||
| for test_file in \ | ||||||
| test_dir/test_config.py \ | ||||||
| test_dir/test_config_comprehensive.py \ | ||||||
| test_dir/test_config_edge_cases.py \ | ||||||
| test_dir/test_config_missing_methods.py; do | ||||||
| echo "Running $test_file with timeout..." | ||||||
| python -m pytest \ | ||||||
| --cov=src.cli_code \ | ||||||
| --cov-append \ | ||||||
| --timeout=60 \ | ||||||
| "$test_file" || echo "Warning: $test_file timed out or failed" | ||||||
| done | ||||||
|
|
||||||
| # Run main tests individually | ||||||
| for test_file in \ | ||||||
| test_dir/test_main.py \ | ||||||
| test_dir/test_main_comprehensive.py \ | ||||||
| test_dir/test_main_edge_cases.py \ | ||||||
| test_dir/test_main_improved.py; do | ||||||
| echo "Running $test_file with timeout..." | ||||||
| python -m pytest \ | ||||||
| --cov=src.cli_code \ | ||||||
| --cov-append \ | ||||||
| --timeout=60 \ | ||||||
| "$test_file" || echo "Warning: $test_file timed out or failed" | ||||||
| done | ||||||
|
|
||||||
| # Run remaining tests individually | ||||||
| for test_file in \ | ||||||
| test_dir/test_task_complete_tool.py \ | ||||||
| test_dir/test_tools_base.py \ | ||||||
| test_dir/test_tools_init_coverage.py \ | ||||||
| test_dir/test_utils.py \ | ||||||
| test_dir/test_utils_comprehensive.py \ | ||||||
| test_dir/test_test_runner_tool.py \ | ||||||
| test_dir/test_basic_functions.py \ | ||||||
| test_dir/test_tools_basic.py \ | ||||||
| test_dir/test_tree_tool_edge_cases.py; do | ||||||
| echo "Running $test_file with timeout..." | ||||||
| python -m pytest \ | ||||||
| --cov=src.cli_code \ | ||||||
| --cov-append \ | ||||||
| --timeout=60 \ | ||||||
| "$test_file" || echo "Warning: $test_file timed out or failed" | ||||||
| done | ||||||
|
|
||||||
| # Generate a final coverage report | ||||||
| python -m pytest \ | ||||||
| --cov=src.cli_code \ | ||||||
| --cov-report=xml:coverage.xml \ | ||||||
| --cov-report=html:coverage_html \ | ||||||
| --cov-report=term | ||||||
|
|
||||||
| echo "Coverage report generated in coverage.xml and coverage_html/" | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,21 +1,131 @@ | ||||||
| #!/bin/bash | ||||||
| # Script to test coverage generation locally | ||||||
| # Script to test coverage generation locally with timeouts to prevent hanging | ||||||
|
|
||||||
| set -e # Exit on error | ||||||
| set -x # Print commands for debugging | ||||||
|
|
||||||
| echo "Starting local test coverage generation..." | ||||||
|
|
||||||
| # Set up coverage directory | ||||||
| mkdir -p coverage_html | ||||||
|
|
||||||
| # Run pytest with coverage enabled and generate reports | ||||||
| # Clean up any pycache files to avoid import conflicts | ||||||
| find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true | ||||||
| find . -name "*.pyc" -delete | ||||||
|
|
||||||
| # Run tests in smaller batches with timeouts | ||||||
| echo "Running test suite with coverage enabled..." | ||||||
|
|
||||||
| # First, run the basic tools tests which are known to work | ||||||
| echo "Running tools tests (known to work well)..." | ||||||
| python -m pytest \ | ||||||
| --cov=src.cli_code \ | ||||||
| --cov-report=xml:coverage.xml \ | ||||||
| --cov-report=html:coverage_html \ | ||||||
| --cov-report=term \ | ||||||
| test_dir/test_file_tools.py test_dir/test_directory_tools.py test_dir/test_system_tools.py | ||||||
| --timeout=30 \ | ||||||
| test_dir/test_file_tools.py \ | ||||||
| test_dir/test_system_tools.py \ | ||||||
| test_dir/test_directory_tools.py \ | ||||||
| test_dir/improved/test_quality_tools.py \ | ||||||
| test_dir/improved/test_summarizer_tool.py \ | ||||||
| test_dir/improved/test_tree_tool.py | ||||||
|
|
||||||
| # Now run the model tests separately | ||||||
| echo "Running model tests..." | ||||||
| python -m pytest \ | ||||||
| --cov=src.cli_code \ | ||||||
| --cov-append \ | ||||||
| --cov-report=xml:coverage.xml \ | ||||||
| --cov-report=html:coverage_html \ | ||||||
| --cov-report=term \ | ||||||
| --timeout=30 \ | ||||||
| test_dir/test_models_base.py \ | ||||||
| test_dir/test_model_basic.py \ | ||||||
| test_dir/test_model_integration.py | ||||||
|
|
||||||
| # Run gemini model tests individually | ||||||
| for test_file in \ | ||||||
| test_dir/test_gemini_model.py \ | ||||||
| test_dir/test_gemini_model_advanced.py \ | ||||||
| test_dir/test_gemini_model_coverage.py \ | ||||||
| test_dir/test_gemini_model_error_handling.py; do | ||||||
| echo "Running $test_file with timeout..." | ||||||
| python -m pytest \ | ||||||
| --cov=src.cli_code \ | ||||||
| --cov-append \ | ||||||
| --timeout=30 \ | ||||||
| "$test_file" || echo "Warning: $test_file timed out or failed" | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Suggested change
|
||||||
| done | ||||||
|
|
||||||
| # Run ollama model tests individually | ||||||
| for test_file in \ | ||||||
| test_dir/test_ollama_model.py \ | ||||||
| test_dir/test_ollama_model_advanced.py \ | ||||||
| test_dir/test_ollama_model_coverage.py \ | ||||||
| test_dir/test_ollama_model_context.py \ | ||||||
| test_dir/test_ollama_model_error_handling.py; do | ||||||
| echo "Running $test_file with timeout..." | ||||||
| python -m pytest \ | ||||||
| --cov=src.cli_code \ | ||||||
| --cov-append \ | ||||||
| --timeout=30 \ | ||||||
| "$test_file" || echo "Warning: $test_file timed out or failed" | ||||||
| done | ||||||
|
|
||||||
| # Run config tests individually | ||||||
| for test_file in \ | ||||||
| test_dir/test_config.py \ | ||||||
| test_dir/test_config_comprehensive.py \ | ||||||
| test_dir/test_config_edge_cases.py \ | ||||||
| test_dir/test_config_missing_methods.py; do | ||||||
| echo "Running $test_file with timeout..." | ||||||
| python -m pytest \ | ||||||
| --cov=src.cli_code \ | ||||||
| --cov-append \ | ||||||
| --timeout=30 \ | ||||||
| "$test_file" || echo "Warning: $test_file timed out or failed" | ||||||
| done | ||||||
|
|
||||||
| # Run main tests individually | ||||||
| for test_file in \ | ||||||
| test_dir/test_main.py \ | ||||||
| test_dir/test_main_comprehensive.py \ | ||||||
| test_dir/test_main_edge_cases.py \ | ||||||
| test_dir/test_main_improved.py; do | ||||||
| echo "Running $test_file with timeout..." | ||||||
| python -m pytest \ | ||||||
| --cov=src.cli_code \ | ||||||
| --cov-append \ | ||||||
| --timeout=30 \ | ||||||
| "$test_file" || echo "Warning: $test_file timed out or failed" | ||||||
| done | ||||||
|
|
||||||
| # Run remaining tests individually | ||||||
| for test_file in \ | ||||||
| test_dir/test_task_complete_tool.py \ | ||||||
| test_dir/test_tools_base.py \ | ||||||
| test_dir/test_tools_init_coverage.py \ | ||||||
| test_dir/test_utils.py \ | ||||||
| test_dir/test_utils_comprehensive.py \ | ||||||
| test_dir/test_test_runner_tool.py \ | ||||||
| test_dir/test_basic_functions.py \ | ||||||
| test_dir/test_tools_basic.py \ | ||||||
| test_dir/test_tree_tool_edge_cases.py; do | ||||||
| echo "Running $test_file with timeout..." | ||||||
| python -m pytest \ | ||||||
| --cov=src.cli_code \ | ||||||
| --cov-append \ | ||||||
| --timeout=30 \ | ||||||
| "$test_file" || echo "Warning: $test_file timed out or failed" | ||||||
| done | ||||||
|
|
||||||
| # Generate a final coverage report | ||||||
| python -m pytest \ | ||||||
| --cov=src.cli_code \ | ||||||
| --cov-report=xml:coverage.xml \ | ||||||
| --cov-report=html:coverage_html \ | ||||||
| --cov-report=term | ||||||
|
|
||||||
| echo "Coverage report generated in coverage.xml and coverage_html/" | ||||||
| echo "This is the format SonarCloud expects." | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the comment here makes the purpose of the timeout less clear. Consider adding a brief comment explaining why the timeout is set, or referring to documentation where the timeout strategy is described.