fix: add Java patterns to instrumented test file cleanup#1338
Merged
mashraf-222 merged 2 commits intoomni-javafrom Feb 4, 2026
Merged
fix: add Java patterns to instrumented test file cleanup#1338mashraf-222 merged 2 commits intoomni-javafrom
mashraf-222 merged 2 commits intoomni-javafrom
Conversation
Java instrumented test files (*Test__perfinstrumented.java and *Test__perfonlyinstrumented.java) were not being cleaned up after optimization, causing subsequent optimizations to fail. The find_leftover_instrumented_test_files() method had regex patterns for Python and JavaScript but was missing Java patterns. Changes: - Add Java patterns to cleanup regex in optimizer.py - Add comprehensive test coverage for Java, Python, JS, and mixed scenarios - All 4 new tests pass Testing: Verified regex matches Java instrumented files correctly and cleanup prevents stale files from blocking optimizations. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Some instrumented test files have numeric suffixes like _2, _3: - FibonacciSeriesTest__perfinstrumented_2.java - KnapsackTest__perfonlyinstrumented_3.java Updated regex to match optional numeric suffix: (?:_\d+)? Updated test to verify files with suffixes are detected. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
misrasaurabh1
approved these changes
Feb 3, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Java optimizations were failing when run sequentially because instrumented test files from previous optimizations were not being cleaned up.
Error:
This made it impossible to run multiple Java optimizations without manually deleting instrumented files between runs.
Root Cause
The
find_leftover_instrumented_test_files()method in optimizer.py has regex patterns to detect and clean up instrumented test files, but it only included patterns for:test_.*__perfinstrumented.py*__perfinstrumented.test.jsJava patterns were missing:
*Test__perfinstrumented.java*Test__perfonlyinstrumented.javaSolution
Added Java patterns to the cleanup regex:
Now the cleanup method (called at line 482 before each optimization) will properly detect and remove Java instrumented test files.
Changes
optimizer.py (line 624-649):
|separator before Java patternstest_cleanup_instrumented_files.py (new file):
Testing
✅ Unit tests:
$ pytest tests/test_cleanup_instrumented_files.py -v test_find_leftover_instrumented_test_files_java PASSED test_find_leftover_instrumented_test_files_python PASSED test_find_leftover_instrumented_test_files_javascript PASSED test_find_leftover_instrumented_test_files_mixed PASSED 4 passed in 0.05s✅ Regex validation:
FibonacciSearchTest__perfonlyinstrumented.java✓ MATCHBruteForceKnapsackTest__perfinstrumented.java✓ MATCHFibonacciSearchTest.java✗ NO MATCH (correct)Impact
This fixes a critical bug blocking Java E2E optimizations.