Skip to content

Commit 10c0086

Browse files
committed
massive tests refactoring
1 parent d7347f4 commit 10c0086

5,076 files changed

Lines changed: 192092 additions & 103846 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

failing_tests.yaml

Lines changed: 9593 additions & 0 deletions
Large diffs are not rendered by default.

src/treemapper/tokens.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def _get_encoder(encoding: str) -> Any | None:
2424
import tiktoken
2525

2626
return tiktoken.get_encoding(encoding)
27-
except (ImportError, KeyError, ValueError):
27+
except Exception:
2828
return None
2929

3030

tests/cases/diff/TODO.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Diff Test Cases Enrichment
2+
3+
## Goal
4+
5+
Enrich all diff test cases with:
6+
7+
1. **Realistic code content** - larger, more representative code snippets
8+
2. **Garbage files** - files with unique markers to test exclusion
9+
3. **Proper diffctx format** - structured assertions
10+
11+
## File Structure
12+
13+
Each test case consists of 3 files:
14+
15+
- `{name}_before.yaml` - codebase state before the change
16+
- `{name}_after.yaml` - codebase state after the change
17+
- `{name}_diffctx.yaml` - assertions for diff context selection
18+
19+
## Garbage Marker Pattern
20+
21+
```
22+
GARBAGE_{CATEGORY}_{NUM}_{DESCRIPTION}_{LETTER}
23+
```
24+
25+
Examples:
26+
27+
- `GARBAGE_CICD_003_ROLLBACK_MARKER_A`
28+
- `GARBAGE_ALGO_005_LOGGING_MARKER_B`
29+
30+
## diffctx Format
31+
32+
```yaml
33+
must_include_files:
34+
- path/to/important/file.py
35+
must_include_content:
36+
- |
37+
actual code block that must appear
38+
must_not_include:
39+
- GARBAGE_MARKER_A
40+
- GarbageClassName
41+
- garbage_file.py
42+
```
43+
44+
---
45+
46+
## Progress
47+
48+
### ✅ Completed
49+
50+
| Directory | Files | Test Cases | Status |
51+
|-----------|-------|------------|--------|
52+
| algorithm | 63 | 21 | ✅ Done |
53+
| cicd | 45 | 15 | ✅ Done |
54+
55+
### 🔄 Remaining
56+
57+
| Directory | Files | Est. Cases | Priority |
58+
|-----------|-------|------------|----------|
59+
| cicd_and_docs | 234 | ~78 | High |
60+
| comprehensive | 81 | ~27 | High |
61+
| config | 15 | ~5 | Medium |
62+
| cpp | 108 | ~36 | Medium |
63+
| csharp | 78 | ~26 | Medium |
64+
| dependencies | 123 | ~41 | High |
65+
| docker | 135 | ~45 | High |
66+
| fragments | 72 | ~24 | Medium |
67+
| frontend | 90 | ~30 | High |
68+
| go | 105 | ~35 | Medium |
69+
| graph | 51 | ~17 | Medium |
70+
| helm | 135 | ~45 | High |
71+
| infrastructure_validation | 15 | ~5 | Low |
72+
| internals | 195 | ~65 | Medium |
73+
| java | 78 | ~26 | Medium |
74+
| javascript | 255 | ~85 | High |
75+
| javascript_extended | 147 | ~49 | Medium |
76+
| json | 45 | ~15 | Low |
77+
| jvm_and_compiled | 216 | ~72 | Medium |
78+
| kubernetes | 120 | ~40 | High |
79+
| merging | 36 | ~12 | Low |
80+
| operations | 18 | ~6 | Low |
81+
| output | 36 | ~12 | Low |
82+
| patterns | 135 | ~45 | Medium |
83+
| php | 60 | ~20 | Low |
84+
| ppr | 105 | ~35 | Medium |
85+
| python | 186 | ~62 | High |
86+
| relations | 21 | ~7 | Low |
87+
| ruby | 60 | ~20 | Low |
88+
| rust | 120 | ~40 | Medium |
89+
| scala | 78 | ~26 | Low |
90+
| scripting | 90 | ~30 | Medium |
91+
| selection | 24 | ~8 | Medium |
92+
| shell | 75 | ~25 | Medium |
93+
| swift | 60 | ~20 | Low |
94+
| terraform | 240 | ~80 | High |
95+
| typescript | 27 | ~9 | Medium |
96+
| yaml | 60 | ~20 | Medium |
97+
98+
**Total remaining:** ~38 directories, ~1100+ test cases
99+
100+
---
101+
102+
## Process
103+
104+
For each test case:
105+
106+
1. **Read** all 3 files (before, after, diffctx)
107+
2. **Check** if already enriched (look for garbage markers)
108+
3. **Enrich** if minimal:
109+
- Add realistic code to before/after
110+
- Add 2 garbage files with unique markers
111+
- Update diffctx to proper format
112+
4. **Write** updated files
113+
114+
## Notes
115+
116+
- Process one directory at a time
117+
- Use consistent garbage marker naming per directory
118+
- Keep code realistic for the test scenario
119+
- Ensure diffctx assertions match actual diff content
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
models/user.py: |
2+
from dataclasses import dataclass, field
3+
from typing import Optional, List
4+
from datetime import datetime
5+
6+
@dataclass
7+
class Address:
8+
street: str
9+
city: str
10+
country: str
11+
postal_code: str
12+
13+
def format(self) -> str:
14+
return f"{self.street}, {self.city}, {self.postal_code}"
15+
16+
@dataclass
17+
class User:
18+
id: int
19+
username: str
20+
email: str
21+
display_name: Optional[str] = None
22+
created_at: datetime = field(default_factory=datetime.now)
23+
address: Optional[Address] = None
24+
roles: List[str] = field(default_factory=list)
25+
26+
def is_admin(self) -> bool:
27+
return "admin" in self.roles
28+
29+
def has_address(self) -> bool:
30+
return self.address is not None
31+
32+
def get_display_name(self) -> str:
33+
return self.display_name or self.username
34+
35+
services/user_service.py: |
36+
from models.user import User, Address
37+
38+
class UserService:
39+
def __init__(self, repository):
40+
self.repository = repository
41+
42+
def create_user(self, username: str, email: str) -> User:
43+
user = User(
44+
id=self.repository.next_id(),
45+
username=username,
46+
email=email
47+
)
48+
self.repository.save(user)
49+
return user
50+
51+
def add_role(self, user: User, role: str) -> None:
52+
if role not in user.roles:
53+
user.roles.append(role)
54+
self.repository.save(user)
55+
56+
def set_address(self, user: User, address: Address) -> None:
57+
user.address = address
58+
self.repository.save(user)
59+
60+
garbage_analytics.py: |
61+
GARBAGE_ALGO_001_ANALYTICS_MARKER_A = "analytics"
62+
GARBAGE_ALGO_001_TRACKER_MARKER_B = True
63+
64+
class AnalyticsTracker:
65+
GARBAGE_ALGO_001_CLASS_MARKER_C = "tracker"
66+
67+
def track(self, event: str) -> None:
68+
pass
69+
70+
garbage_notifications.py: |
71+
GARBAGE_ALGO_001_NOTIFY_MARKER_D = "notify"
72+
GARBAGE_ALGO_001_PUSH_MARKER_E = 42
73+
74+
class PushService:
75+
GARBAGE_ALGO_001_PUSH_CLASS_F = True
76+
77+
def send(self, token: str, message: str) -> bool:
78+
return True
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
models/user.py: |
2+
from dataclasses import dataclass, field
3+
from typing import Optional, List
4+
from datetime import datetime
5+
6+
@dataclass
7+
class Address:
8+
street: str
9+
city: str
10+
country: str
11+
postal_code: str
12+
13+
def format(self) -> str:
14+
return f"{self.street}, {self.city}, {self.postal_code}"
15+
16+
@dataclass
17+
class User:
18+
id: int
19+
username: str
20+
email: str
21+
created_at: datetime = field(default_factory=datetime.now)
22+
address: Optional[Address] = None
23+
roles: List[str] = field(default_factory=list)
24+
25+
def is_admin(self) -> bool:
26+
return "admin" in self.roles
27+
28+
def has_address(self) -> bool:
29+
return self.address is not None
30+
31+
services/user_service.py: |
32+
from models.user import User, Address
33+
34+
class UserService:
35+
def __init__(self, repository):
36+
self.repository = repository
37+
38+
def create_user(self, username: str, email: str) -> User:
39+
user = User(
40+
id=self.repository.next_id(),
41+
username=username,
42+
email=email
43+
)
44+
self.repository.save(user)
45+
return user
46+
47+
def add_role(self, user: User, role: str) -> None:
48+
if role not in user.roles:
49+
user.roles.append(role)
50+
self.repository.save(user)
51+
52+
def set_address(self, user: User, address: Address) -> None:
53+
user.address = address
54+
self.repository.save(user)
55+
56+
garbage_analytics.py: |
57+
GARBAGE_ALGO_001_ANALYTICS_MARKER_A = "analytics"
58+
GARBAGE_ALGO_001_TRACKER_MARKER_B = True
59+
60+
class AnalyticsTracker:
61+
GARBAGE_ALGO_001_CLASS_MARKER_C = "tracker"
62+
63+
def track(self, event: str) -> None:
64+
pass
65+
66+
garbage_notifications.py: |
67+
GARBAGE_ALGO_001_NOTIFY_MARKER_D = "notify"
68+
GARBAGE_ALGO_001_PUSH_MARKER_E = 42
69+
70+
class PushService:
71+
GARBAGE_ALGO_001_PUSH_CLASS_F = True
72+
73+
def send(self, token: str, message: str) -> bool:
74+
return True
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
must_include_files:
2+
- models/user.py
3+
must_include_content:
4+
- |
5+
@dataclass
6+
class User:
7+
id: int
8+
username: str
9+
email: str
10+
display_name: Optional[str] = None
11+
created_at: datetime = field(default_factory=datetime.now)
12+
address: Optional[Address] = None
13+
roles: List[str] = field(default_factory=list)
14+
15+
def is_admin(self) -> bool:
16+
return "admin" in self.roles
17+
18+
def has_address(self) -> bool:
19+
return self.address is not None
20+
21+
def get_display_name(self) -> str:
22+
return self.display_name or self.username
23+
must_not_include:
24+
- GARBAGE_ALGO_001_ANALYTICS_MARKER_A
25+
- GARBAGE_ALGO_001_TRACKER_MARKER_B
26+
- GARBAGE_ALGO_001_CLASS_MARKER_C
27+
- GARBAGE_ALGO_001_NOTIFY_MARKER_D
28+
- GARBAGE_ALGO_001_PUSH_MARKER_E
29+
- GARBAGE_ALGO_001_PUSH_CLASS_F
30+
- AnalyticsTracker
31+
- PushService
32+
- garbage_analytics.py
33+
- garbage_notifications.py
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
decorators.py: |
2+
from functools import wraps
3+
from typing import Callable, Any
4+
5+
def log_calls(func: Callable) -> Callable:
6+
@wraps(func)
7+
def wrapper(*args: Any, **kwargs: Any) -> Any:
8+
print(f"Calling {func.__name__}")
9+
result = func(*args, **kwargs)
10+
print(f"Finished {func.__name__}")
11+
return result
12+
return wrapper
13+
14+
def retry(max_attempts: int = 3) -> Callable:
15+
def decorator(func: Callable) -> Callable:
16+
@wraps(func)
17+
def wrapper(*args: Any, **kwargs: Any) -> Any:
18+
for attempt in range(max_attempts):
19+
try:
20+
return func(*args, **kwargs)
21+
except Exception as e:
22+
if attempt == max_attempts - 1:
23+
raise
24+
return None
25+
return wrapper
26+
return decorator
27+
28+
def validate_args(func: Callable) -> Callable:
29+
@wraps(func)
30+
def wrapper(*args: Any, **kwargs: Any) -> Any:
31+
if not args and not kwargs:
32+
raise ValueError("No arguments provided")
33+
return func(*args, **kwargs)
34+
return wrapper
35+
36+
services/api_client.py: |
37+
from decorators import log_calls, retry, validate_args
38+
39+
class ApiClient:
40+
def __init__(self, base_url: str):
41+
self.base_url = base_url
42+
self.timeout = 30
43+
44+
@log_calls
45+
@retry(max_attempts=5)
46+
def fetch_data(self, endpoint: str) -> dict:
47+
url = f"{self.base_url}/{endpoint}"
48+
return {"url": url, "status": "ok", "timeout": self.timeout}
49+
50+
@validate_args
51+
def post_data(self, endpoint: str, data: dict) -> dict:
52+
return {"endpoint": endpoint, "data": data}
53+
54+
garbage_cache.py: |
55+
GARBAGE_ALGO_002_CACHE_MARKER_A = "cache"
56+
GARBAGE_ALGO_002_REDIS_MARKER_B = True
57+
58+
class CacheManager:
59+
GARBAGE_ALGO_002_CLASS_MARKER_C = "manager"
60+
61+
def get(self, key: str) -> None:
62+
pass
63+
64+
garbage_metrics.py: |
65+
GARBAGE_ALGO_002_METRICS_MARKER_D = "metrics"
66+
GARBAGE_ALGO_002_COUNTER_MARKER_E = 0
67+
68+
class MetricsCollector:
69+
GARBAGE_ALGO_002_COLLECTOR_F = True
70+
71+
def record(self, name: str, value: float) -> None:
72+
pass

0 commit comments

Comments
 (0)