feat: Add comprehensive tests for contentPattern and glob pattern matching

- Implemented final verification tests for contentPattern to validate behavior with empty strings, dangerous patterns, and normal patterns.
- Created glob pattern matching tests to verify regex conversion and matching functionality.
- Developed infinite loop risk tests using Worker threads to isolate potential blocking operations.
- Introduced optimized contentPattern tests to validate improvements in the findMatches function.
- Added verification tests to assess the effectiveness of contentPattern optimizations.
- Conducted safety tests for contentPattern to identify edge cases and potential vulnerabilities.
- Implemented unrestricted loop tests to analyze infinite loop risks without match limits.
- Developed tests for zero-width pattern detection logic to ensure proper handling of dangerous regex patterns.
This commit is contained in:
catlog22
2026-02-09 11:13:01 +08:00
parent dfe153778c
commit 964292ebdb
62 changed files with 7588 additions and 374 deletions

View File

@@ -231,6 +231,26 @@ class TestHDBSCANStrategy:
assert all_indices == set(range(len(sample_results)))
def test_cluster_supports_cosine_metric(
self, sample_results: List[SearchResult], mock_embeddings
):
"""Test HDBSCANStrategy can run with metric='cosine' (via precomputed distances)."""
try:
from codexlens.search.clustering import HDBSCANStrategy
except ImportError:
pytest.skip("hdbscan not installed")
config = ClusteringConfig(min_cluster_size=2, min_samples=1, metric="cosine")
strategy = HDBSCANStrategy(config)
clusters = strategy.cluster(mock_embeddings, sample_results)
all_indices = set()
for cluster in clusters:
all_indices.update(cluster)
assert all_indices == set(range(len(sample_results)))
def test_cluster_empty_results(self, hdbscan_strategy):
"""Test cluster() with empty results."""
import numpy as np