Skip to content

Commit 4d680af

Browse files
simoncozensfelipesanches
authored andcommitted
Rename "tests"->"shaping tests" and fix rationale linebreaks
1 parent a679767 commit 4d680af

1 file changed

Lines changed: 27 additions & 50 deletions

File tree

Lib/fontbakery/profiles/shaping.py

Lines changed: 27 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def get_shaping_parameters(test, configuration):
103103

104104
# This is a very generic "do something with shaping" test runner.
105105
# It'll be given concrete meaning later.
106-
def run_a_set_of_tests(
106+
def run_a_set_of_shaping_tests(
107107
config, ttFont, run_a_test, test_filter, generate_report, preparation=None
108108
):
109109
filename = Path(ttFont.reader.file.name)
@@ -141,7 +141,7 @@ def run_a_set_of_tests(
141141
if preparation:
142142
extra_data = preparation(ttFont, configuration)
143143

144-
failed_tests = []
144+
failed_shaping_tests = []
145145
for test in shaping_tests:
146146
if not test_filter(test, configuration):
147147
continue
@@ -161,15 +161,15 @@ def run_a_set_of_tests(
161161
continue
162162

163163
run_a_test(
164-
filename, vharfbuzz, test, configuration, failed_tests, extra_data
164+
filename, vharfbuzz, test, configuration, failed_shaping_tests, extra_data
165165
)
166166
ran_a_test = True
167167

168168
if ran_a_test:
169-
if not failed_tests:
169+
if not failed_shaping_tests:
170170
yield PASS, f"{shaping_file}: No regression detected"
171171
else:
172-
yield from generate_report(vharfbuzz, shaping_file, failed_tests)
172+
yield from generate_report(vharfbuzz, shaping_file, failed_shaping_tests)
173173

174174
if not shaping_file_found:
175175
yield SKIP, "No test files found."
@@ -180,21 +180,14 @@ def run_a_set_of_tests(
180180
@check(
181181
id="com.google.fonts/check/shaping/regression",
182182
rationale="""
183-
Fonts with complex layout rules can benefit from regression tests
184-
to ensure that the rules are behaving as designed. This checks runs
185-
a test suite and compares expected shaping against actual shaping,
186-
reporting any differences.
187-
188-
Test suites should be written by the font engineer and referenced in
189-
the fontbakery configuration file. For more information about write
190-
test files and how to configure fontbakery to read the test suites,
191-
see https://simoncozens.github.io/tdd-for-otl/
183+
Fonts with complex layout rules can benefit from regression tests to ensure that the rules are behaving as designed. This checks runs a shaping test suite and compares expected shaping against actual shaping, reporting any differences.
184+
Shaping test suites should be written by the font engineer and referenced in the fontbakery configuration file. For more information about write shaping test files and how to configure fontbakery to read the shaping test suites, see https://simoncozens.github.io/tdd-for-otl/
192185
""",
193186
misc_metadata={"request": "https://github.com/googlefonts/fontbakery/pull/3223"},
194187
)
195188
def com_google_fonts_check_shaping_regression(config, ttFont):
196189
"""Check that texts shape as per expectation"""
197-
yield from run_a_set_of_tests(
190+
yield from run_a_set_of_shaping_tests(
198191
config,
199192
ttFont,
200193
run_shaping_regression,
@@ -204,7 +197,7 @@ def com_google_fonts_check_shaping_regression(config, ttFont):
204197

205198

206199
def run_shaping_regression(
207-
filename, vharfbuzz, test, configuration, failed_tests, extra_data
200+
filename, vharfbuzz, test, configuration, failed_shaping_tests, extra_data
208201
):
209202
shaping_text = test["input"]
210203
parameters = get_shaping_parameters(test, configuration)
@@ -217,14 +210,14 @@ def run_shaping_regression(
217210
)
218211

219212
if output_serialized != expectation:
220-
failed_tests.append((test, expectation, output_buf, output_serialized))
213+
failed_shaping_tests.append((test, expectation, output_buf, output_serialized))
221214

222215

223-
def gereate_shaping_regression_report(vharfbuzz, shaping_file, failed_tests):
216+
def gereate_shaping_regression_report(vharfbuzz, shaping_file, failed_shaping_tests):
224217
report_items = []
225218
header = f"{shaping_file}: Expected and actual shaping not matching"
226219
report_items.append(create_report_item(vharfbuzz, header, type="header"))
227-
for test, expected, output_buf, output_serialized in failed_tests:
220+
for test, expected, output_buf, output_serialized in failed_shaping_tests:
228221
extra_data = {
229222
k: test[k]
230223
for k in ["script", "language", "direction", "features"]
@@ -250,23 +243,14 @@ def gereate_shaping_regression_report(vharfbuzz, shaping_file, failed_tests):
250243
@check(
251244
id="com.google.fonts/check/shaping/forbidden",
252245
rationale="""
253-
Fonts with complex layout rules can benefit from regression tests
254-
to ensure that the rules are behaving as designed. This checks runs
255-
a test suite and reports if any glyphs are generated in the shaping which
256-
should not be produced. (For example, .notdef glyphs, visible viramas,
257-
etc.)
258-
259-
Test suites should be written by the font engineer and referenced in
260-
the fontbakery configuration file. For more information about write
261-
test files and how to configure fontbakery to read the test suites,
262-
see https://simoncozens.github.io/tdd-for-otl/
246+
Fonts with complex layout rules can benefit from regression tests to ensure that the rules are behaving as designed. This checks runs a shaping test suite and reports if any glyphs are generated in the shaping which should not be produced. (For example, .notdef glyphs, visible viramas, etc.)
247+
Shaping test suites should be written by the font engineer and referenced in the fontbakery configuration file. For more information about write shaping test files and how to configure fontbakery to read the shaping test suites, see https://simoncozens.github.io/tdd-for-otl/
263248
""",
264249
misc_metadata={"request": "https://github.com/googlefonts/fontbakery/pull/3223"},
265250
)
266-
@check(id="com.google.fonts/check/shaping/forbidden")
267251
def com_google_fonts_check_shaping_forbidden(config, ttFont):
268252
"""Check that no forbidden glyphs are found while shaping"""
269-
yield from run_a_set_of_tests(
253+
yield from run_a_set_of_shaping_tests(
270254
config,
271255
ttFont,
272256
run_forbidden_glyph_test,
@@ -276,7 +260,7 @@ def com_google_fonts_check_shaping_forbidden(config, ttFont):
276260

277261

278262
def run_forbidden_glyph_test(
279-
filename, vharfbuzz, test, configuration, failed_tests, extra_data
263+
filename, vharfbuzz, test, configuration, failed_shaping_tests, extra_data
280264
):
281265
is_stringbrewer = (
282266
get_from_test_with_default(test, configuration, "input_type", "string")
@@ -298,14 +282,14 @@ def run_forbidden_glyph_test(
298282
glyph_names = output_serialized.split("|")
299283
for forbidden in forbidden_glyphs:
300284
if forbidden in glyph_names:
301-
failed_tests.append((shaping_text, output_buf, forbidden))
285+
failed_shaping_tests.append((shaping_text, output_buf, forbidden))
302286

303287

304-
def forbidden_glyph_test_results(vharfbuzz, shaping_file, failed_tests):
288+
def forbidden_glyph_test_results(vharfbuzz, shaping_file, failed_shaping_tests):
305289
report_items = []
306290
msg = f"{shaping_file}: Forbidden glyphs found while shaping"
307291
report_items.append(create_report_item(vharfbuzz, msg, type="header"))
308-
for shaping_text, buf, forbidden in failed_tests:
292+
for shaping_text, buf, forbidden in failed_shaping_tests:
309293
msg = f"{shaping_text} produced '{forbidden}'"
310294
report_items.append(
311295
create_report_item(vharfbuzz, msg, text=shaping_text, buf1=buf)
@@ -317,21 +301,14 @@ def forbidden_glyph_test_results(vharfbuzz, shaping_file, failed_tests):
317301
@check(
318302
id="com.google.fonts/check/shaping/collides",
319303
rationale="""
320-
Fonts with complex layout rules can benefit from regression tests
321-
to ensure that the rules are behaving as designed. This checks runs
322-
a test suite and reports instances where the glyphs collide in
323-
unexpected ways.
324-
325-
Test suites should be written by the font engineer and referenced in
326-
the fontbakery configuration file. For more information about write
327-
test files and how to configure fontbakery to read the test suites,
328-
see https://simoncozens.github.io/tdd-for-otl/
304+
Fonts with complex layout rules can benefit from regression tests to ensure that the rules are behaving as designed. This checks runs a shaping test suite and reports instances where the glyphs collide in unexpected ways.
305+
Shaping test suites should be written by the font engineer and referenced in the fontbakery configuration file. For more information about write shaping test files and how to configure fontbakery to read the shaping test suites, see https://simoncozens.github.io/tdd-for-otl/
329306
""",
330307
misc_metadata={"request": "https://github.com/googlefonts/fontbakery/pull/3223"},
331308
)
332309
def com_google_fonts_check_shaping_collides(config, ttFont):
333310
"""Check that no collisions are found while shaping"""
334-
yield from run_a_set_of_tests(
311+
yield from run_a_set_of_shaping_tests(
335312
config,
336313
ttFont,
337314
run_collides_glyph_test,
@@ -356,7 +333,7 @@ def setup_glyph_collides(ttFont, configuration):
356333

357334

358335
def run_collides_glyph_test(
359-
filename, vharfbuzz, test, configuration, failed_tests, extra_data
336+
filename, vharfbuzz, test, configuration, failed_shaping_tests, extra_data
360337
):
361338
col = extra_data["collidoscope"]
362339
is_stringbrewer = (
@@ -384,15 +361,15 @@ def run_collides_glyph_test(
384361
if bumps:
385362
draw = fix_svg(col.draw_overlaps(glyphs, collisions))
386363

387-
failed_tests.append((shaping_text, bumps, draw, output_buf))
364+
failed_shaping_tests.append((shaping_text, bumps, draw, output_buf))
388365

389366

390-
def collides_glyph_test_results(vharfbuzz, shaping_file, failed_tests):
367+
def collides_glyph_test_results(vharfbuzz, shaping_file, failed_shaping_tests):
391368
report_items = []
392369
seen_bumps = {}
393-
msg = f"{shaping_file}: %i collisions found while shaping" % len(failed_tests)
370+
msg = f"{shaping_file}: %i collisions found while shaping" % len(failed_shaping_tests)
394371
report_items.append(create_report_item(vharfbuzz, msg, type="header"))
395-
for shaping_text, bumps, draw, buf in failed_tests:
372+
for shaping_text, bumps, draw, buf in failed_shaping_tests:
396373
# Make HTML report here.
397374
if tuple(bumps) in seen_bumps:
398375
continue

0 commit comments

Comments
 (0)