You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The insert_test method no longer deletes old entries for a file, which can lead to duplicate or stale records when tests are re-discovered. Consider clearing or replacing entries by file_path and file_hash.
Add a DELETE statement before inserting to remove stale cache entries for the same file and hash, and call self.connection.commit() after the insert so the database updates actually persist.
def insert_test(
self,
file_path: str,
file_hash: str,
qualified_name_with_modules_from_root: str,
function_name: str,
test_class: str,
test_function: str,
test_type: TestType,
line_number: int,
col_number: int,
) -> None:
+ # purge old entries for this file and hash+ self.cur.execute(+ "DELETE FROM discovered_tests WHERE file_path = ? AND file_hash = ?",+ (file_path, file_hash),+ )
test_type_value = test_type.value if hasattr(test_type, "value") else test_type
self.cur.execute(
"INSERT INTO discovered_tests VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
(
file_path,
file_hash,
qualified_name_with_modules_from_root,
function_name,
test_class,
test_function,
test_type_value,
line_number,
col_number,
),
)
+ self.connection.commit()
Suggestion importance[1-10]: 7
__
Why: Adding a DELETE before the insert prevents stale rows accumulating, and calling self.connection.commit() ensures the new entries are persisted immediately.
Medium
General
Limit worker pool correctly
Bound the worker pool size to the number of uncached files rather than the total file map so you don’t spawn idle processes when most files are already cached.
-max_workers = min(len(file_to_test_map) or 1, multiprocessing.cpu_count())+# after segregating uncached_files+max_workers = min(len(uncached_files) or 1, multiprocessing.cpu_count())
Suggestion importance[1-10]: 6
__
Why: Bounding max_workers to len(uncached_files) avoids spawning idle processes when many files are already cached, improving resource usage.
Low
Use serializable worker results
Serializing custom FunctionCalledInTest objects across processes can fail; convert each result into plain dictionaries or tuples before returning and rebuild the objects in the main process.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
Enhancement, Tests
Description
Parallelize unit test discovery using processes
Introduce caching to skip processed files
Return total discovered count from discovery
Update call sites and tests for new API
Changes walkthrough 📝
discover_unit_tests.py
Add parallel test discovery and cachingcodeflash/discovery/discover_unit_tests.py
functions_to_optimize.py
Unpack discover_unit_tests return tuplecodeflash/discovery/functions_to_optimize.py
optimizer.py
Unpack discovery results in optimizercodeflash/optimization/optimizer.py
concolic_testing.py
Support new discovery return in concolic testingcodeflash/verification/concolic_testing.py
test_unit_test_discovery.py
Update tests for new discover_unit_tests signaturetests/test_unit_test_discovery.py