Skip to content

Commit 566ce1b

Browse files
fix: Java line profiler timeout and test categorization issues
Fixed two critical bugs preventing Java optimization E2E workflows: Issue 1: Line profiler timeout was too short (15s) for Maven operations, causing timeouts before tests could complete. Maven needs time for JVM startup, dependency resolution, and test execution. Issue 2: Test result categorization failed to match original test file names to instrumented test files, causing all existing unit tests to show as 0 passed/failed instead of their actual results. Both issues blocked Java optimization from completing successfully. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent afe79a0 commit 566ce1b

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

codeflash/languages/java/test_runner.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,12 +1508,16 @@ def run_line_profile_tests(
15081508
run_env["CODEFLASH_LINE_PROFILE_OUTPUT"] = str(line_profile_output_file)
15091509

15101510
# Run tests once with profiling
1511-
logger.debug("Running line profiling tests (single run)")
1511+
# Maven needs substantial timeout for JVM startup + test execution
1512+
# Use minimum of 120s to account for Maven overhead, or larger if specified
1513+
min_timeout = 120
1514+
effective_timeout = max(timeout or min_timeout, min_timeout)
1515+
logger.debug("Running line profiling tests (single run) with timeout=%ds", effective_timeout)
15121516
result = _run_maven_tests(
15131517
maven_root,
15141518
test_paths,
15151519
run_env,
1516-
timeout=timeout or 120,
1520+
timeout=effective_timeout,
15171521
mode="line_profile",
15181522
test_module=test_module,
15191523
)

codeflash/verification/parse_test_output.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,12 @@ def parse_test_xml(
10661066
if not test_file_path.exists():
10671067
logger.warning(f"Could not find the test for file name - {test_file_path} ")
10681068
continue
1069+
# Try to match by instrumented file path first (for generated/instrumented tests)
10691070
test_type = test_files.get_test_type_by_instrumented_file_path(test_file_path)
1071+
if test_type is None:
1072+
# Fallback: try to match by original file path (for existing unit tests that were instrumented)
1073+
# JUnit XML may reference the original class name, resolving to the original file path
1074+
test_type = test_files.get_test_type_by_original_file_path(test_file_path)
10701075
if test_type is None:
10711076
# Log registered paths for debugging
10721077
registered_paths = [str(tf.instrumented_behavior_file_path) for tf in test_files.test_files]

0 commit comments

Comments
 (0)