Skip to content

Commit f0188ad

Browse files
committed
test(python): guard that use_ray is forwarded through the facade
use_ray is already lifted all the way up (CLDK.analysis → PythonAnalysis → PyCodeanalyzer → AnalysisOptions.using_ray), but unlike use_codeql and cache_dir it had no regression test. Add test_use_ray_forwarded_through_facade mirroring the existing use_codeql guard, so the facade can't silently drop the flag.
1 parent 582fb81 commit f0188ad

1 file changed

Lines changed: 27 additions & 9 deletions

File tree

tests/analysis/python/test_python_analysis.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ class FakeBackend:
4949
def __init__(self, **kwargs):
5050
captured.update(kwargs)
5151

52-
monkeypatch.setattr(
53-
"cldk.analysis.python.python_analysis.PyCodeanalyzer", FakeBackend
54-
)
52+
monkeypatch.setattr("cldk.analysis.python.python_analysis.PyCodeanalyzer", FakeBackend)
5553

5654
CLDK(language="python").analysis(project_path=tmp_path, use_codeql=False)
5755
assert captured["use_codeql"] is False
@@ -62,6 +60,30 @@ def __init__(self, **kwargs):
6260
assert captured["use_codeql"] is True
6361

6462

63+
def test_use_ray_forwarded_through_facade(monkeypatch, tmp_path):
64+
"""Regression: CLDK.analysis() must forward use_ray down to the backend.
65+
66+
use_ray is a Python-only option lifted all the way up to the public API
67+
(CLDK.analysis → PythonAnalysis → PyCodeanalyzer → AnalysisOptions.using_ray);
68+
the façade must not silently drop it (mirrors the use_codeql guard).
69+
"""
70+
captured = {}
71+
72+
class FakeBackend:
73+
def __init__(self, **kwargs):
74+
captured.update(kwargs)
75+
76+
monkeypatch.setattr("cldk.analysis.python.python_analysis.PyCodeanalyzer", FakeBackend)
77+
78+
CLDK(language="python").analysis(project_path=tmp_path, use_ray=True)
79+
assert captured["use_ray"] is True
80+
81+
# Off by default; the façade must forward that faithfully too.
82+
captured.clear()
83+
CLDK(language="python").analysis(project_path=tmp_path)
84+
assert captured["use_ray"] is False
85+
86+
6587
def test_cache_dir_forwarded_through_facade(monkeypatch, tmp_path):
6688
"""cache_dir must reach the backend as cache_dir (not analysis_backend_path)."""
6789
captured = {}
@@ -70,9 +92,7 @@ class FakeBackend:
7092
def __init__(self, **kwargs):
7193
captured.update(kwargs)
7294

73-
monkeypatch.setattr(
74-
"cldk.analysis.python.python_analysis.PyCodeanalyzer", FakeBackend
75-
)
95+
monkeypatch.setattr("cldk.analysis.python.python_analysis.PyCodeanalyzer", FakeBackend)
7696

7797
cache = tmp_path / "mycache"
7898
CLDK(language="python").analysis(project_path=tmp_path, cache_dir=cache)
@@ -83,6 +103,4 @@ def __init__(self, **kwargs):
83103
def test_python_rejects_java_only_analysis_backend_path(tmp_path):
84104
"""analysis_backend_path is Java-only; Python mode must reject it."""
85105
with pytest.raises(CldkInitializationException, match="Java-only"):
86-
CLDK(language="python").analysis(
87-
project_path=tmp_path, analysis_backend_path="/some/jar/dir"
88-
)
106+
CLDK(language="python").analysis(project_path=tmp_path, analysis_backend_path="/some/jar/dir")

0 commit comments

Comments
 (0)