This repository was archived by the owner on Apr 23, 2025. It is now read-only.
forked from raizamartin/gemini-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Fix testing regression #10
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e84589e
Fix pytest.ini timeout setting format
ipv1337 8dfbaa8
Add script to find hanging tests
ipv1337 19e9e13
Update scripts/find_hanging_tests.sh
ipv1337 03dd001
Fix PR issues: Make timeouts configurable, improve error handling, an…
ipv1337 a1af2eb
Fix CI failures: Make test directory configurable, improve error hand…
ipv1337 03e6569
CI fix: Improve path handling in GitHub Actions environment
ipv1337 f036972
Update GitHub workflow to better handle missing tests and make CI mor…
ipv1337 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| #!/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) - use environment variable if set, otherwise default to 15 seconds | ||
| TIMEOUT=${TEST_TIMEOUT:-15} | ||
| echo "Using timeout value of $TIMEOUT seconds (set TEST_TIMEOUT env var to change)" | ||
|
|
||
| # Set up logging | ||
| LOG_DIR="test_logs" | ||
| mkdir -p "$LOG_DIR" | ||
| TIMESTAMP=$(date +"%Y%m%d_%H%M%S") | ||
| SUMMARY_LOG="$LOG_DIR/hanging_tests_summary_${TIMESTAMP}.log" | ||
| echo "Hanging test scan started at $(date)" > "$SUMMARY_LOG" | ||
| echo "Timeout value: $TIMEOUT seconds" >> "$SUMMARY_LOG" | ||
|
|
||
| # Function to run a single test with timeout | ||
| run_test_with_timeout() { | ||
| TEST_FILE=$1 | ||
| echo "Testing: $TEST_FILE" | tee -a "$SUMMARY_LOG" | ||
| LOG_FILE="$LOG_DIR/$(basename "$TEST_FILE").log" | ||
|
|
||
| # Run test with timeout and capture output to log file | ||
| if timeout $TIMEOUT python -m pytest "$TEST_FILE" -v > "$LOG_FILE" 2>&1; then | ||
| echo "✅ $TEST_FILE completed successfully" | tee -a "$SUMMARY_LOG" | ||
| return 0 | ||
| else | ||
| EXIT_CODE=$? | ||
| if [ $EXIT_CODE -eq 124 ]; then | ||
| echo "❌ $TEST_FILE TIMEOUT - Test is hanging!" | tee -a "$SUMMARY_LOG" | ||
| else | ||
| echo "❌ $TEST_FILE failed with exit code $EXIT_CODE" | tee -a "$SUMMARY_LOG" | ||
| # Print more details about the failure | ||
| echo "Last 10 lines of log:" | tee -a "$SUMMARY_LOG" | ||
| tail -10 "$LOG_FILE" | tee -a "$SUMMARY_LOG" | ||
| fi | ||
| return $EXIT_CODE | ||
| fi | ||
| echo "----------------------------------------" | tee -a "$SUMMARY_LOG" | ||
| } | ||
|
|
||
| # Determine test directory | ||
| TEST_DIR="test_dir" | ||
|
|
||
| # Check if TEST_DIR environment variable is set | ||
| if [ -n "$TEST_DIR_ENV" ]; then | ||
| TEST_DIR="$TEST_DIR_ENV" | ||
| echo "Using test directory from environment: $TEST_DIR" | tee -a "$SUMMARY_LOG" | ||
| fi | ||
|
|
||
| # Verify test directory exists | ||
| if [ ! -d "$TEST_DIR" ]; then | ||
| echo "Error: Test directory $TEST_DIR does not exist!" | tee -a "$SUMMARY_LOG" | ||
| echo "Current directory: $(pwd)" | tee -a "$SUMMARY_LOG" | ||
| echo "Available directories:" | tee -a "$SUMMARY_LOG" | ||
| ls -la | tee -a "$SUMMARY_LOG" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Automatically find all test files | ||
| echo "Finding test files in $TEST_DIR..." | tee -a "$SUMMARY_LOG" | ||
| TEST_FILES=$(find "$TEST_DIR" -name "test_*.py" -type f) | ||
|
|
||
| # Check if we found any test files | ||
| if [ -z "$TEST_FILES" ]; then | ||
| echo "Error: No test files found in $TEST_DIR/" | tee -a "$SUMMARY_LOG" | ||
| echo "Available files in $TEST_DIR:" | tee -a "$SUMMARY_LOG" | ||
| find "$TEST_DIR" -type f | tee -a "$SUMMARY_LOG" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Count the files found | ||
| FILE_COUNT=$(echo "$TEST_FILES" | wc -l) | ||
| echo "Found $FILE_COUNT test files to check" | tee -a "$SUMMARY_LOG" | ||
| echo "----------------------------------------" | tee -a "$SUMMARY_LOG" | ||
|
|
||
| # Run each test file individually | ||
| FAILED_TESTS=() | ||
| HANGING_TESTS=() | ||
|
|
||
| for TEST_FILE in $TEST_FILES; do | ||
| run_test_with_timeout "$TEST_FILE" | ||
| EXIT_CODE=$? | ||
|
|
||
| if [ $EXIT_CODE -eq 124 ]; then | ||
| HANGING_TESTS+=("$TEST_FILE") | ||
| elif [ $EXIT_CODE -ne 0 ]; then | ||
| FAILED_TESTS+=("$TEST_FILE") | ||
| fi | ||
| echo "----------------------------------------" | tee -a "$SUMMARY_LOG" | ||
| done | ||
|
|
||
| # Print summary at the end | ||
| echo "Test scan complete." | tee -a "$SUMMARY_LOG" | ||
| echo "----------------------------------------" | tee -a "$SUMMARY_LOG" | ||
| echo "Summary:" | tee -a "$SUMMARY_LOG" | ||
| echo "Total test files: $FILE_COUNT" | tee -a "$SUMMARY_LOG" | ||
| echo "Failed tests: ${#FAILED_TESTS[@]}" | tee -a "$SUMMARY_LOG" | ||
| echo "Hanging tests: ${#HANGING_TESTS[@]}" | tee -a "$SUMMARY_LOG" | ||
| echo "Log files available in: $LOG_DIR" | tee -a "$SUMMARY_LOG" | ||
| echo "Summary log: $SUMMARY_LOG" | tee -a "$SUMMARY_LOG" | ||
|
|
||
| if [ ${#HANGING_TESTS[@]} -gt 0 ]; then | ||
| echo "" | tee -a "$SUMMARY_LOG" | ||
| echo "Hanging tests:" | tee -a "$SUMMARY_LOG" | ||
| for TEST in "${HANGING_TESTS[@]}"; do | ||
| echo "- $TEST" | tee -a "$SUMMARY_LOG" | ||
| done | ||
| fi | ||
|
|
||
| if [ ${#FAILED_TESTS[@]} -gt 0 ]; then | ||
| echo "" | tee -a "$SUMMARY_LOG" | ||
| echo "Failed tests:" | tee -a "$SUMMARY_LOG" | ||
| for TEST in "${FAILED_TESTS[@]}"; do | ||
| echo "- $TEST" | tee -a "$SUMMARY_LOG" | ||
| done | ||
| fi | ||
|
|
||
| # Exit with error if any tests were hanging or failed | ||
| if [ ${#HANGING_TESTS[@]} -gt 0 ] || [ ${#FAILED_TESTS[@]} -gt 0 ]; then | ||
| echo "⚠️ Some tests failed or timed out. Check logs for details." | tee -a "$SUMMARY_LOG" | ||
| # Only exit with error in CI environment | ||
| if [ -n "$CI" ]; then | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| echo "All tests passed successfully." | tee -a "$SUMMARY_LOG" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.