fix: address PR review feedback
- Fix mypy error: assert coverage_xml_path is not None before
generate_jacoco_report call (control flow guarantees it but mypy
can't infer it)
- Remove unused _JAVA_RESOURCES_DIR constant from build_tools.py
- Make AgentDispatcher routing robust: check startsWith("config=") or
contains(",config=") instead of bare substring match, preventing
false positive on paths containing "config="
- Drop redundant exception arg from logger.exception call
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
dcf9edb21d
commit
9870785469
5 changed files with 10 additions and 5 deletions
|
|
@ -20,7 +20,8 @@ import java.lang.instrument.Instrumentation;
|
|||
public class AgentDispatcher {
|
||||
|
||||
static boolean isProfilerMode(String agentArgs) {
|
||||
return agentArgs != null && agentArgs.contains("config=");
|
||||
return agentArgs != null
|
||||
&& (agentArgs.startsWith("config=") || agentArgs.contains(",config="));
|
||||
}
|
||||
|
||||
public static void premain(String agentArgs, Instrumentation inst) throws Exception {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class AgentDispatcherTest {
|
|||
|
||||
@Test
|
||||
void profilerModeWithMultipleArgs() {
|
||||
assertTrue(AgentDispatcher.isProfilerMode("config=/tmp/config.json,output=results"));
|
||||
assertTrue(AgentDispatcher.isProfilerMode("output=results,config=/tmp/config.json"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -21,6 +21,11 @@ class AgentDispatcherTest {
|
|||
assertFalse(AgentDispatcher.isProfilerMode("destfile=/tmp/jacoco.exec"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void jacocoModeWhenPathContainsConfigSubstring() {
|
||||
assertFalse(AgentDispatcher.isProfilerMode("destfile=/home/config=/jacoco.exec"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void jacocoModeWhenNullArgs() {
|
||||
assertFalse(AgentDispatcher.isProfilerMode(null));
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ CODEFLASH_RUNTIME_JAR_NAME = f"codeflash-runtime-{CODEFLASH_RUNTIME_VERSION}.jar
|
|||
|
||||
JACOCO_PLUGIN_VERSION = "0.8.13"
|
||||
|
||||
_JAVA_RESOURCES_DIR = Path(__file__).parent / "resources"
|
||||
|
||||
|
||||
# MVN_CENTRAL_TODO: Uncomment once codeflash-runtime is published to Maven Central.
|
||||
# Steps:
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -228,7 +228,7 @@ def generate_jacoco_report(exec_file: Path, classfiles_dir: Path, sourcefiles_di
|
|||
logger.error("JaCoCo CLI report failed (rc=%d): %s", result.returncode, result.stderr)
|
||||
return False
|
||||
except Exception as e:
|
||||
logger.exception("Failed to generate JaCoCo report: %s", e)
|
||||
logger.exception("Failed to generate JaCoCo report")
|
||||
return False
|
||||
|
||||
|
||||
|
|
@ -710,6 +710,7 @@ def run_behavioral_tests(
|
|||
classfiles_dir = target_dir / "classes"
|
||||
module_base = (maven_root / test_module) if test_module else project_root
|
||||
sourcefiles_dir = module_base / "src" / "main" / "java"
|
||||
assert coverage_xml_path is not None
|
||||
if not generate_jacoco_report(jacoco_exec_path, classfiles_dir, sourcefiles_dir, coverage_xml_path):
|
||||
logger.warning("JaCoCo report generation failed — coverage data will be unavailable")
|
||||
coverage_xml_path = None
|
||||
|
|
|
|||
Loading…
Reference in a new issue