Skip to content

Commit 224ee24

Browse files
committed
keep bitmap-glyph-limits.js within the time of a test under coverage
1 parent 736ed1f commit 224ee24

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎tests/bitmap-glyph-limits.js‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ const {Image, LimitError} = require('..');
44
// bitmap glyphs (sbix, CBDT) are bounded like the rest of a render: their PNGs count before they are decoded (also those
55
// that turn out damaged), and a glyph scaled from a tiny strike to the font size isn't allocated past the output
66
// (Bun's JavaScriptCore rasterizes several times slower than V8)
7-
const slack = process.versions.bun ? 4 : 1;
7+
// (under coverage everything takes several times as long: the budgets are reached in time only without it)
8+
const slack = (process.versions.bun ? 4 : 1) * (process.env.NODE_V8_COVERAGE ? 4 : 1);
89

910
// a collection before a memory check, so that the rasters a render made aren't counted as kept (Node and Bun; where
1011
// no collector can be had, the memory checks are skipped)
@@ -45,10 +46,10 @@ const NS = 'xmlns="http://www.w3.org/2000/svg"';
4546
});
4647
}],
4748
// the rasters of outline glyphs at a huge size were kept with the font: 62 letters at size 6000 in a 10x10 box
48-
// kept 774 MB, a size more ran out of memory
49-
['62 huge letters', async () => {
49+
// kept 774 MB (24 of them over 280 MB), a size more ran out of memory
50+
['24 huge letters', async () => {
5051
const data = fs.readFileSync(`${__dirname}/fonts/opensans bold.ttf`);
51-
for (const size of [6000]) for (const c of 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') await Image.renderText(c, {font: data, size, width: 10, height: 10, maxPixels: 100});
52+
for (const size of [6000]) for (const c of 'ABCDEFGHIJKLMNOPQRSTUVWX') await Image.renderText(c, {font: data, size, width: 10, height: 10, maxPixels: 100});
5253
}],
5354
// color glyphs (COLR) were kept for every text color: a new color each render grew without end
5455
['color glyphs in 200 colors', async () => {
@@ -57,7 +58,8 @@ const NS = 'xmlns="http://www.w3.org/2000/svg"';
5758
}],
5859
// glyphs too large to keep, over each other (no advance) 1000 times at size 8000: drawn again each time, 260 s
5960
['2000 huge glyphs without advance', () => Image.renderText(text(2).repeat(1000), {font: font('zero'), size: 8000, width: 10, height: 10, maxPixels: 100})],
60-
]) {
61+
].filter(([name]) => !process.env.NODE_V8_COVERAGE || !/huge|colors/.test(name))) {
62+
// (not under coverage: the huge cases take most of what a test may take there)
6163
collect?.();
6264
const begin = Date.now(), before = process.memoryUsage().arrayBuffers;
6365
const result = await run().then(() => 'ok', err => err);

0 commit comments

Comments
 (0)