Skip to content

Commit b02a2b6

Browse files
committed
Fix using old check ids in excluded checks
This was broken since the old ids in exclude_checks were never mapped to new ones.
1 parent 01287ef commit b02a2b6

2 files changed

Lines changed: 38 additions & 8 deletions

File tree

Lib/fontbakery/checkrunner.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ def _get(self, name, iterargs, condition=False):
139139
f"This can't happen: asked for {name} but nothing provides it."
140140
)
141141

142-
def _get_check_dependencies(
143-
self, identity: Identity
144-
) -> Union[
142+
def _get_check_dependencies(self, identity: Identity) -> Union[
145143
Tuple[None, dict], # Either we got args
146144
Tuple[Subresult, None], # or we return a Skipped message
147145
]:
@@ -238,6 +236,17 @@ def _run_check(self, identity: Identity):
238236

239237
@property
240238
def order(self) -> Tuple[Identity, ...]:
239+
# map old excluded check ids to new ones
240+
_exclude_checks = None
241+
if self._exclude_checks:
242+
_exclude_checks = []
243+
for excluded in self._exclude_checks:
244+
if excluded in old_to_new:
245+
self.legacy_checkid_references.add(excluded)
246+
_exclude_checks.append(old_to_new[excluded])
247+
else:
248+
_exclude_checks.append(excluded)
249+
241250
_order = []
242251
for section in self.profile.sections:
243252
for check in section.checks:
@@ -260,15 +269,13 @@ def order(self) -> Tuple[Identity, ...]:
260269
if not selected_via_legacy_checkid and not selected_via_new_checkid:
261270
continue
262271

263-
if self._exclude_checks:
264-
if any(excluded in check.id for excluded in self._exclude_checks):
272+
if _exclude_checks:
273+
if any(excluded in check.id for excluded in _exclude_checks):
265274
continue
266275

267276
if check.id in self.new_to_old:
268277
for legacy in self.new_to_old[check.id]:
269-
if any(
270-
excluded in legacy for excluded in self._exclude_checks
271-
):
278+
if any(excluded in legacy for excluded in _exclude_checks):
272279
self.legacy_checkid_references.add(legacy)
273280
continue
274281

tests/test_external_profile.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,26 @@ def test_in_and_exclude_checks_default():
9696

9797
checks = profile_checks(fakemodule, {"explicit_checks": ["opentype/unitsperem"]})
9898
assert checks == ["opentype/unitsperem"]
99+
100+
101+
def test_exclude_checks_old_ids():
102+
from fontbakery.legacy_checkids import renaming_map
103+
104+
fakemodule = FakeModule()
105+
setattr(
106+
fakemodule,
107+
"PROFILE",
108+
{
109+
"include_profiles": ["microsoft"],
110+
"sections": {},
111+
},
112+
)
113+
114+
old = "com.microsoft/check/vendor_url"
115+
new = renaming_map[old]
116+
117+
checks = profile_checks(fakemodule)
118+
assert new in checks
119+
120+
checks = profile_checks(fakemodule, {"exclude_checks": [old]})
121+
assert new not in checks

0 commit comments

Comments
 (0)