Skip to content

Commit 04b0dbd

Browse files
authored
Merge pull request #1674 from codeflash-ai/fix/java/pr-test-path-resolution
fix: resolve Java test paths with .java extension in PR results
2 parents 380e55b + 23db0d7 commit 04b0dbd

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

codeflash/result/create_pr.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from codeflash.code_utils.tabulate import tabulate
1515
from codeflash.code_utils.time_utils import format_perf, format_time
1616
from codeflash.github.PrComment import FileDiffContent, PrComment
17+
from codeflash.languages import is_java
1718
from codeflash.languages.python.static_analysis.code_replacer import is_zero_diff
1819
from codeflash.result.critic import performance_gain
1920

@@ -138,6 +139,14 @@ def existing_tests_source_for(
138139
logger.debug(f"[PR-DEBUG] Mapped {instrumented_abs_path.name} -> {abs_path.name}")
139140
else:
140141
logger.debug(f"[PR-DEBUG] No mapping found for {instrumented_abs_path.name}")
142+
elif is_java():
143+
# Java: test_module_path is the class name (e.g., "BubbleSortTest")
144+
# Search non_generated_tests for a matching .java file
145+
abs_path = (test_cfg.tests_project_rootdir / f"{test_module_path}.java").resolve()
146+
for candidate in non_generated_tests:
147+
if candidate.stem == test_module_path:
148+
abs_path = candidate
149+
break
141150
else:
142151
# Python: convert module name to path
143152
abs_path = Path(test_module_path.replace(".", os.sep)).with_suffix(".py").resolve()

0 commit comments

Comments
 (0)