Skip to content

Commit 74cbe2a

Browse files
misrasaurabh1claude
andcommitted
fix: Windows compatibility for Java config detection tests
- Use Path comparisons instead of forward-slash substring matching - Avoid parse_args() in test (reads stdin on Windows) — use Namespace directly Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent dae9b48 commit 74cbe2a

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

tests/test_languages/test_java/test_java_config_detection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def test_defaults_when_dirs_missing(self, tmp_path: Path) -> None:
136136
config = parse_java_project_config(tmp_path)
137137
assert config is not None
138138
# Falls back to default paths even if they don't exist
139-
assert "src/main/java" in config["module_root"]
139+
assert str(tmp_path / "src" / "main" / "java") == config["module_root"]
140140
assert config["language"] == "java"
141141

142142

@@ -185,7 +185,7 @@ def test_properties_override_auto_detection(self, tmp_path: Path) -> None:
185185
config = parse_java_project_config(tmp_path)
186186
assert config is not None
187187
# Should use custom paths from properties, not auto-detected standard paths
188-
assert "custom/src" in config["module_root"]
188+
assert config["module_root"] == str((tmp_path / "custom" / "src").resolve())
189189

190190
def test_no_properties_uses_defaults(self, tmp_path: Path) -> None:
191191
(tmp_path / "pom.xml").write_text(

tests/test_languages/test_java/test_jfr_parser.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -277,23 +277,24 @@ def test_java_project_root_is_build_root_not_module(self, tmp_path: Path, monkey
277277

278278
def test_project_root_is_path_not_string(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
279279
"""project_root from process_pyproject_config should be a Path for Java projects."""
280+
from argparse import Namespace
281+
280282
(tmp_path / "pom.xml").write_text("<project/>", encoding="utf-8")
281283
src = tmp_path / "src" / "main" / "java"
282284
src.mkdir(parents=True)
283285
test = tmp_path / "src" / "test" / "java"
284286
test.mkdir(parents=True)
285287
monkeypatch.chdir(tmp_path)
286288

287-
import sys
288-
from argparse import Namespace
289-
290-
sys.argv = ["codeflash", "optimize", "java", "-jar", "app.jar"]
291-
from codeflash.cli_cmds.cli import parse_args, process_pyproject_config
292-
293-
from codeflash.cli_cmds.cli import _build_parser
294-
_build_parser.cache_clear()
289+
from codeflash.cli_cmds.cli import process_pyproject_config
295290

296-
args = parse_args()
291+
# Create a minimal args namespace matching what parse_args produces
292+
args = Namespace(
293+
config_file=None, module_root=None, tests_root=None, benchmarks_root=None,
294+
ignore_paths=None, pytest_cmd=None, formatter_cmds=None, disable_telemetry=None,
295+
disable_imports_sorting=None, git_remote=None, override_fixtures=None,
296+
benchmark=False, verbose=False, version=False, show_config=False, reset_config=False,
297+
)
297298
args = process_pyproject_config(args)
298299

299300
assert hasattr(args, "project_root")

0 commit comments

Comments
 (0)