mirror of
https://github.com/codeflash-ai/codeflash.git
synced 2026-05-04 18:25:17 +00:00
fix: handle numbered suffixes in Java instrumented test files
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>
This commit is contained in:
parent
d69b8c5aa0
commit
1b911c0dbf
3 changed files with 15 additions and 5 deletions
|
|
@ -3,3 +3,4 @@
|
|||
[tool.codeflash]
|
||||
module-root = "src/main/java"
|
||||
tests-root = "src/test/java"
|
||||
formatter-cmds = []
|
||||
|
|
|
|||
|
|
@ -639,6 +639,8 @@ class Optimizer:
|
|||
Java patterns:
|
||||
- '*Test__perfinstrumented.java'
|
||||
- '*Test__perfonlyinstrumented.java'
|
||||
- '*Test__perfinstrumented_{n}.java' (with optional numeric suffix)
|
||||
- '*Test__perfonlyinstrumented_{n}.java' (with optional numeric suffix)
|
||||
|
||||
Returns a list of matching file paths.
|
||||
"""
|
||||
|
|
@ -650,8 +652,8 @@ class Optimizer:
|
|||
r"test.*__perf_test_\d?\.py|test_.*__unit_test_\d?\.py|test_.*__perfinstrumented\.py|test_.*__perfonlyinstrumented\.py|"
|
||||
# JavaScript/TypeScript patterns (new naming with .test/.spec preserved)
|
||||
r".*__perfinstrumented\.(?:test|spec)\.(?:js|ts|jsx|tsx)|.*__perfonlyinstrumented\.(?:test|spec)\.(?:js|ts|jsx|tsx)|"
|
||||
# Java patterns
|
||||
r".*Test__perfinstrumented\.java|.*Test__perfonlyinstrumented\.java"
|
||||
# Java patterns (with optional numeric suffix _2, _3, etc.)
|
||||
r".*Test__perfinstrumented(?:_\d+)?\.java|.*Test__perfonlyinstrumented(?:_\d+)?\.java"
|
||||
r")$"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,13 @@ def test_find_leftover_instrumented_test_files_java(tmp_path):
|
|||
# Create Java instrumented test files (should be found)
|
||||
java_perf1 = test_root / "FibonacciTest__perfinstrumented.java"
|
||||
java_perf2 = test_root / "KnapsackTest__perfonlyinstrumented.java"
|
||||
# Create files with numeric suffixes (also should be found)
|
||||
java_perf3 = test_root / "FibonacciTest__perfinstrumented_2.java"
|
||||
java_perf4 = test_root / "KnapsackTest__perfonlyinstrumented_3.java"
|
||||
java_perf1.touch()
|
||||
java_perf2.touch()
|
||||
java_perf3.touch()
|
||||
java_perf4.touch()
|
||||
|
||||
# Create normal Java test file (should NOT be found)
|
||||
normal_test = test_root / "CalculatorTest.java"
|
||||
|
|
@ -24,15 +29,17 @@ def test_find_leftover_instrumented_test_files_java(tmp_path):
|
|||
leftover_files = Optimizer.find_leftover_instrumented_test_files(tmp_path)
|
||||
leftover_names = {f.name for f in leftover_files}
|
||||
|
||||
# Assert instrumented files are found
|
||||
# Assert instrumented files are found (including those with numeric suffixes)
|
||||
assert "FibonacciTest__perfinstrumented.java" in leftover_names
|
||||
assert "KnapsackTest__perfonlyinstrumented.java" in leftover_names
|
||||
assert "FibonacciTest__perfinstrumented_2.java" in leftover_names
|
||||
assert "KnapsackTest__perfonlyinstrumented_3.java" in leftover_names
|
||||
|
||||
# Assert normal test file is NOT found
|
||||
assert "CalculatorTest.java" not in leftover_names
|
||||
|
||||
# Should find exactly 2 files
|
||||
assert len(leftover_files) == 2
|
||||
# Should find exactly 4 files
|
||||
assert len(leftover_files) == 4
|
||||
|
||||
|
||||
def test_find_leftover_instrumented_test_files_python(tmp_path):
|
||||
|
|
|
|||
Loading…
Reference in a new issue