Skip to content

Commit b4d6f95

Browse files
committed
remove js runtime in codeflash client
1 parent 69fb9cc commit b4d6f95

8 files changed

Lines changed: 34 additions & 2375 deletions

File tree

codeflash/languages/javascript/comparator.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,31 @@
1212
from pathlib import Path
1313

1414
from codeflash.cli_cmds.console import logger
15-
from codeflash.languages.javascript.runtime import get_compare_results_path
1615
from codeflash.models.models import TestDiff, TestDiffScope
1716

1817

18+
def _get_compare_results_script(project_root: Path | None = None) -> Path | None:
19+
"""Find the compare-results.js script from the installed codeflash npm package.
20+
21+
Args:
22+
project_root: Project root directory where node_modules is installed.
23+
24+
Returns:
25+
Path to compare-results.js if found, None otherwise.
26+
"""
27+
search_dirs = []
28+
if project_root:
29+
search_dirs.append(project_root)
30+
search_dirs.append(Path.cwd())
31+
32+
for base_dir in search_dirs:
33+
script_path = base_dir / "node_modules" / "codeflash" / "runtime" / "compare-results.js"
34+
if script_path.exists():
35+
return script_path
36+
37+
return None
38+
39+
1940
def compare_test_results(
2041
original_sqlite_path: Path,
2142
candidate_sqlite_path: Path,
@@ -26,8 +47,8 @@ def compare_test_results(
2647
2748
This function calls a Node.js script that:
2849
1. Reads serialized behavior data from both SQLite databases
29-
2. Deserializes using codeflash-serializer.js
30-
3. Compares using codeflash-comparator.js (handles Map, Set, Date, etc. natively)
50+
2. Deserializes using the codeflash serializer module
51+
3. Compares using the codeflash comparator module (handles Map, Set, Date, etc. natively)
3152
4. Returns comparison results as JSON
3253
3354
Args:
@@ -39,10 +60,13 @@ def compare_test_results(
3960
Returns:
4061
Tuple of (all_equivalent, list of TestDiff objects).
4162
"""
42-
script_path = comparator_script or get_compare_results_path()
63+
script_path = comparator_script or _get_compare_results_script(project_root)
4364

44-
if not script_path.exists():
45-
logger.error(f"JavaScript comparator script not found: {script_path}")
65+
if not script_path or not script_path.exists():
66+
logger.error(
67+
"JavaScript comparator script not found. "
68+
"Please ensure the 'codeflash' npm package is installed in your project."
69+
)
4670
return False, []
4771

4872
if not original_sqlite_path.exists():

codeflash/languages/javascript/runtime/__init__.py

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)