Skip to content

Commit 0779dc2

Browse files
committed
./.../beman-submodule update --remote
1 parent 1e758df commit 0779dc2

File tree

3 files changed

+85
-3
lines changed

3 files changed

+85
-3
lines changed

infra/.beman_submodule

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[beman_submodule]
22
remote=https://github.com/bemanproject/infra.git
3-
commit_hash=78de7eb4ff54bd12c9abb790107edc86bcda07d8
3+
commit_hash=8e80cc3049fcc450805349da381edddd7a920dff

infra/tools/beman-tidy/beman_tidy/lib/checks/beman_standard/readme.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,42 @@ def fix(self):
7272
pass
7373

7474

75-
# TODO README.PURPOSE
75+
@register_beman_standard_check("README.IMPLEMENTS")
76+
class ReadmeImplementsCheck(ReadmeBaseCheck):
77+
def __init__(self, repo_info, beman_standard_check_config):
78+
super().__init__(repo_info, beman_standard_check_config)
79+
80+
def check(self):
81+
lines = self.read_lines_strip()
7682

83+
# Match the pattern to start with "Implements:" and then have a paper reference and a wg21.link URL.
84+
# Examples of valid lines:
85+
# **Implements**: [Standard Library Concepts (P0898R3)](https://wg21.link/P0898R3).
86+
# **Implements**: [Give *std::optional* Range Support (P3168R2)](https://wg21.link/P3168R2) and [`std::optional<T&>` (P2988R5)](https://wg21.link/P2988R5)
87+
# **Implements**: [.... (PxyzwRr)](https://wg21.link/PxyzwRr), [.... (PabcdRr)](https://wg21.link/PabcdRr), and [.... (PijklRr)](https://wg21.link/PijklRr),
88+
regex = r"^\*\*Implements\*\*:\s+.*\bP\d{4}R\d+\b.*wg21\.link/\S+"
89+
90+
# Count how many lines match the regex
91+
implement_lines = 0
92+
for line in lines:
93+
if re.match(regex, line):
94+
implement_lines += 1
95+
96+
# If there is exactly one "Implements:" line, it is valid
97+
if implement_lines == 1:
98+
return True
99+
100+
# Invalid/missing/duplicate "Implements:" line
101+
self.log(
102+
f"Invalid/missing/duplicate 'Implements:' line in '{self.path}'. See https://github.com/bemanproject/beman/blob/main/docs/BEMAN_STANDARD.md#readmeimplements for more information."
103+
)
104+
return False
77105

78-
# TODO README.IMPLEMENTS
106+
def fix(self):
107+
self.log(
108+
"Please write a Implements line in README.md file. See https://github.com/bemanproject/beman/blob/main/docs/BEMAN_STANDARD.md#readmeimplements for the desired format."
109+
)
110+
return False
79111

80112

81113
@register_beman_standard_check("README.LIBRARY_STATUS")

infra/tools/beman-tidy/tests/lib/checks/beman_standard/readme/test_readme.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from beman_tidy.lib.checks.beman_standard.readme import (
1414
ReadmeTitleCheck,
1515
ReadmeBadgesCheck,
16+
ReadmeImplementsCheck,
1617
ReadmeLibraryStatusCheck,
1718
)
1819

@@ -130,6 +131,55 @@ def test__README_BADGES__fix_inplace(repo_info, beman_standard_check_config):
130131
pass
131132

132133

134+
def test__README_IMPLEMENTS__valid(repo_info, beman_standard_check_config):
135+
"""
136+
Test that a valid README.md "Implements" passes the check
137+
"""
138+
valid_readme_paths = [
139+
Path(f"{valid_prefix}/README-v1.md"),
140+
Path(f"{valid_prefix}/README-v2.md"),
141+
Path(f"{valid_prefix}/README-v3.md"),
142+
Path(f"{valid_prefix}/README-v4.md"),
143+
]
144+
145+
run_check_for_each_path(
146+
True,
147+
valid_readme_paths,
148+
ReadmeImplementsCheck,
149+
repo_info,
150+
beman_standard_check_config,
151+
)
152+
153+
154+
def test__README_IMPLEMENTS__invalid(repo_info, beman_standard_check_config):
155+
"""
156+
Test that an invalid README.md "Implements" fails the check
157+
"""
158+
invalid_readme_paths = [
159+
Path(f"{invalid_prefix}/invalid.md"),
160+
Path(f"{invalid_prefix}/invalid-implements-v1.md"),
161+
Path(f"{invalid_prefix}/invalid-implements-v2.md"),
162+
Path(f"{invalid_prefix}/invalid-implements-v3.md"),
163+
Path(f"{invalid_prefix}/invalid-implements-v4.md"),
164+
]
165+
166+
run_check_for_each_path(
167+
False,
168+
invalid_readme_paths,
169+
ReadmeImplementsCheck,
170+
repo_info,
171+
beman_standard_check_config,
172+
)
173+
174+
175+
@pytest.mark.skip(reason="NOT implemented")
176+
def test__README_IMPLEMENTS__fix_inplace(repo_info, beman_standard_check_config):
177+
"""
178+
Test that the fix method corrects an invalid README.md "Implements"
179+
"""
180+
pass
181+
182+
133183
def test__README_LIBRARY_STATUS__valid(repo_info, beman_standard_check_config):
134184
"""
135185
Test that a valid README.md library status passes the check.

0 commit comments

Comments
 (0)