Skip to content

Commit 7c5f8ce

Browse files
committed
Revert "debug"
This reverts commit e61d445.
1 parent e61d445 commit 7c5f8ce

File tree

1 file changed

+20
-48
lines changed

1 file changed

+20
-48
lines changed

codeflash/discovery/discover_unit_tests.py

Lines changed: 20 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# ruff: noqa: SLF001
22
from __future__ import annotations
33

4-
import concurrent.futures
54
import hashlib
6-
import multiprocessing
75
import os
86
import pickle
97
import re
@@ -25,8 +23,6 @@
2523
from codeflash.models.models import CodePosition, FunctionCalledInTest, TestsInFile, TestType
2624

2725
if TYPE_CHECKING:
28-
from multiprocessing.synchronize import Lock
29-
3026
from codeflash.verification.verification_utils import TestConfig
3127

3228

@@ -288,33 +284,23 @@ def discover_parameters_unittest(function_name: str) -> tuple[bool, str, str | N
288284

289285

290286
def _process_single_test_file(
291-
test_file: Path,
292-
functions: list[TestsInFile],
293-
project_root_path: Path,
294-
test_framework: str,
295-
jedi_lock: Optional[Lock] = None,
287+
test_file: Path, functions: list[TestsInFile], project_root_path: Path, test_framework: str
296288
) -> tuple[Path, set]:
297289
import jedi
298290

299291
local_function_to_test_map = set()
300292

301293
try:
302-
if jedi_lock is not None:
303-
jedi_lock.acquire()
304-
try:
305-
jedi_project = jedi.Project(path=project_root_path)
306-
script = jedi.Script(path=test_file, project=jedi_project)
307-
test_functions = set()
308-
309-
all_names = script.get_names(all_scopes=True, references=True)
310-
all_defs = script.get_names(all_scopes=True, definitions=True)
311-
all_names_top = script.get_names(all_scopes=True)
312-
313-
top_level_functions = {name.name: name for name in all_names_top if name.type == "function"}
314-
top_level_classes = {name.name: name for name in all_names_top if name.type == "class"}
315-
finally:
316-
if jedi_lock is not None:
317-
jedi_lock.release()
294+
jedi_project = jedi.Project(path=project_root_path)
295+
script = jedi.Script(path=test_file, project=jedi_project)
296+
test_functions = set()
297+
298+
all_names = script.get_names(all_scopes=True, references=True)
299+
all_defs = script.get_names(all_scopes=True, definitions=True)
300+
all_names_top = script.get_names(all_scopes=True)
301+
302+
top_level_functions = {name.name: name for name in all_names_top if name.type == "function"}
303+
top_level_classes = {name.name: name for name in all_names_top if name.type == "class"}
318304
except Exception as e:
319305
logger.debug(f"Failed to get jedi script for {test_file}: {e}")
320306
return test_file, local_function_to_test_map
@@ -393,13 +379,7 @@ def _process_single_test_file(
393379
continue
394380

395381
try:
396-
if jedi_lock is not None:
397-
jedi_lock.acquire()
398-
try:
399-
definition = name.goto(follow_imports=True, follow_builtin_imports=False)
400-
finally:
401-
if jedi_lock is not None:
402-
jedi_lock.release()
382+
definition = name.goto(follow_imports=True, follow_builtin_imports=False)
403383
except Exception as e:
404384
logger.debug(str(e))
405385
continue
@@ -453,25 +433,17 @@ def process_test_files(
453433
test_framework = cfg.test_framework
454434

455435
function_to_test_map = defaultdict(set)
456-
jedi_lock = multiprocessing.Manager().Lock()
457-
458-
with (
459-
test_files_progress_bar(total=len(file_to_test_map), description="Processing test files") as (
460-
progress,
461-
task_id,
462-
),
463-
concurrent.futures.ProcessPoolExecutor() as executor,
436+
437+
with test_files_progress_bar(total=len(file_to_test_map), description="Processing test files") as (
438+
progress,
439+
task_id,
464440
):
465-
futures = {
466-
executor.submit(
467-
_process_single_test_file, test_file, functions, project_root_path, test_framework, jedi_lock
468-
): (test_file, functions)
469-
for test_file, functions in file_to_test_map.items()
470-
}
471-
for future in concurrent.futures.as_completed(futures):
472-
_, local_results = future.result()
441+
for test_file, functions in file_to_test_map.items():
442+
_, local_results = _process_single_test_file(test_file, functions, project_root_path, test_framework)
443+
473444
for qualified_name, function_called_in_test in local_results:
474445
function_to_test_map[qualified_name].add(function_called_in_test)
446+
475447
progress.advance(task_id)
476448

477449
function_to_tests_dict = {function: list(tests) for function, tests in function_to_test_map.items()}

0 commit comments

Comments
 (0)