-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
95 lines (71 loc) · 2.34 KB
/
Copy pathconftest.py
File metadata and controls
95 lines (71 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import json
import os
import re
import pytest
import yaml
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
def parse_frontmatter(text):
"""Extract YAML frontmatter from a markdown/mdc file."""
match = re.match(r"^---\s*\n(.*?)\n---\s*\n", text, re.DOTALL)
if not match:
return None
return yaml.safe_load(match.group(1))
def get_markdown_sections(text):
"""Extract H2 section titles from markdown text."""
return re.findall(r"^## (.+)$", text, re.MULTILINE)
def get_body(text):
"""Return everything after the YAML frontmatter."""
match = re.match(r"^---\s*\n.*?\n---\s*\n(.*)$", text, re.DOTALL)
if match:
return match.group(1)
return text
@pytest.fixture(scope="session")
def manifest():
path = os.path.join(REPO_ROOT, ".cursor-plugin", "plugin.json")
with open(path, "r", encoding="utf-8") as f:
return json.load(f)
@pytest.fixture(scope="session")
def skill_dirs():
skills_path = os.path.join(REPO_ROOT, "skills")
if not os.path.isdir(skills_path):
return []
return sorted(
[
d
for d in os.listdir(skills_path)
if os.path.isdir(os.path.join(skills_path, d))
]
)
@pytest.fixture(scope="session")
def rule_files():
rules_path = os.path.join(REPO_ROOT, "rules")
if not os.path.isdir(rules_path):
return []
return sorted(
[f for f in os.listdir(rules_path) if f.endswith(".mdc")]
)
@pytest.fixture(scope="session")
def readme_text():
path = os.path.join(REPO_ROOT, "README.md")
with open(path, "r", encoding="utf-8") as f:
return f.read()
@pytest.fixture(scope="session")
def claude_text():
path = os.path.join(REPO_ROOT, "CLAUDE.md")
with open(path, "r", encoding="utf-8") as f:
return f.read()
@pytest.fixture(scope="session")
def contributing_text():
path = os.path.join(REPO_ROOT, "CONTRIBUTING.md")
with open(path, "r", encoding="utf-8") as f:
return f.read()
@pytest.fixture(scope="session")
def changelog_text():
path = os.path.join(REPO_ROOT, "CHANGELOG.md")
with open(path, "r", encoding="utf-8") as f:
return f.read()
@pytest.fixture(scope="session")
def roadmap_text():
path = os.path.join(REPO_ROOT, "ROADMAP.md")
with open(path, "r", encoding="utf-8") as f:
return f.read()