@@ -297,7 +297,6 @@ def _process_single_test_file(
297297
298298 jedi_project = jedi .Project (path = project_root_path )
299299 results = []
300- cache_entries = []
301300
302301 try :
303302 script = jedi .Script (path = test_file , project = jedi_project )
@@ -323,7 +322,7 @@ def _process_single_test_file(
323322 reference_names .append ((name , m .group (1 )))
324323 except Exception as e :
325324 logger .debug (f"Failed to get jedi script for { test_file } : { e } " )
326- return str (test_file ), results , len (results ), cache_entries
325+ return str (test_file ), results , len (results ), []
327326
328327 if test_framework == "pytest" :
329328 for function in functions :
@@ -430,19 +429,7 @@ def _process_single_test_file(
430429 )
431430 results .append ((qualified_name_with_modules_from_root , function_called_in_test ))
432431
433- cache_entries .append (
434- {
435- "qualified_name_with_modules_from_root" : qualified_name_with_modules_from_root ,
436- "function_name" : scope ,
437- "test_class" : scope_test_class ,
438- "test_function" : scope_test_function ,
439- "test_type" : test_type ,
440- "line_number" : name .line ,
441- "col_number" : name .column ,
442- }
443- )
444-
445- return str (test_file ), results , len (results ), cache_entries
432+ return str (test_file ), results , len (results ), []
446433
447434
448435def process_test_files (
@@ -453,88 +440,43 @@ def process_test_files(
453440 function_to_test_map = defaultdict (set )
454441 total_count = 0
455442
456- tests_cache = TestsCache ()
457-
458443 max_workers = min (len (file_to_test_map ) or 1 , multiprocessing .cpu_count ())
459444
460445 with test_files_progress_bar (total = len (file_to_test_map ), description = "Processing test files" ) as (
461446 progress ,
462447 task_id ,
463448 ):
464- cached_files = {}
465- uncached_files = {}
466-
467- for test_file , functions in file_to_test_map .items ():
468- file_hash = TestsCache .compute_file_hash (str (test_file ))
469- cached_tests = tests_cache .get_tests_for_file (str (test_file ), file_hash )
470-
471- if cached_tests :
472- cached_files [test_file ] = (functions , cached_tests , file_hash )
473- else :
474- uncached_files [test_file ] = functions
475-
476- for test_file , (_functions , cached_tests , file_hash ) in cached_files .items ():
477- cur = tests_cache .cur
478- cur .execute (
479- "SELECT qualified_name_with_modules_from_root FROM discovered_tests WHERE file_path = ? AND file_hash = ?" ,
480- (str (test_file ), file_hash ),
481- )
482- qualified_names = [row [0 ] for row in cur .fetchall ()]
483- for cached_test , qualified_name in zip (cached_tests , qualified_names ):
484- function_to_test_map [qualified_name ].add (cached_test )
485- total_count += len (cached_tests )
486- progress .advance (task_id )
487-
488- if len (uncached_files ) == 1 or max_workers == 1 :
489- for test_file , functions in uncached_files .items ():
490- _ , results , count , cache_entries = _process_single_test_file (
449+ if len (file_to_test_map ) == 1 or max_workers == 1 :
450+ for test_file , functions in file_to_test_map .items ():
451+ _ , results , count , _ = _process_single_test_file (
491452 test_file , functions , project_root_path , test_framework
492453 )
493454 total_count += count
494455
495- file_hash = TestsCache .compute_file_hash (str (test_file ))
496- for cache_entry in cache_entries :
497- tests_cache .insert_test (file_path = str (test_file ), file_hash = file_hash , ** cache_entry )
498-
499456 for qualified_name , function_called in results :
500457 function_to_test_map [qualified_name ].add (function_called )
501458 progress .advance (task_id )
502459 else :
503- all_cache_entries = []
504460 with ProcessPoolExecutor (max_workers = max_workers ) as executor :
505461 future_to_file = {
506462 executor .submit (
507463 _process_single_test_file , test_file , functions , project_root_path , test_framework
508464 ): test_file
509- for test_file , functions in uncached_files .items ()
465+ for test_file , functions in file_to_test_map .items ()
510466 }
511467
512468 for future in as_completed (future_to_file ):
513469 try :
514- _ , results , count , cache_entries = future .result ()
470+ _ , results , count , _ = future .result ()
515471 total_count += count
516472
517- test_file = future_to_file [future ]
518- file_hash = TestsCache .compute_file_hash (str (test_file ))
519-
520- # Collect cache entries for batch insertion
521- for cache_entry in cache_entries :
522- cache_entry ['file_path' ] = str (test_file )
523- cache_entry ['file_hash' ] = file_hash
524- all_cache_entries .append (cache_entry )
525-
526473 for qualified_name , function_called in results :
527474 function_to_test_map [qualified_name ].add (function_called )
528475 progress .advance (task_id )
529476 except Exception as e :
530477 test_file = future_to_file [future ]
531478 logger .error (f"Error processing test file { test_file } : { e } " )
532479 progress .advance (task_id )
533-
534- # Batch insert all cache entries after all workers complete
535- for cache_entry in all_cache_entries :
536- tests_cache .insert_test (** cache_entry )
537480
538- tests_cache .close ()
539481 function_to_tests_dict = {function : list (tests ) for function , tests in function_to_test_map .items ()}
540482 return function_to_tests_dict , total_count
0 commit comments