Skip to content

Commit 7b8f117

Browse files
committed
test(tree-sitter-bash): pin the budgets on the 500KB parse cases
Both cases relied on the default budget, whose timeout is 50ms of wall clock, so a loaded CI runner failed them for machine speed rather than for the node accounting they were written to guard. Pinning a generous timeout and a node cap far stricter than the default keeps the assertion and drops the race.
1 parent 569f4c4 commit 7b8f117

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

packages/tree-sitter-bash/test/parse.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,11 +441,15 @@ describe('adversarial input', () => {
441441
}
442442
});
443443

444-
it('parses a 500KB double-quoted string under the default budget', () => {
444+
it('parses a 500KB double-quoted string within the node budget', () => {
445445
// Regression: per-character budget.tick() used to burn the 50k node cap
446446
// on long strings even though only a handful of nodes are created.
447+
// Budgets are pinned rather than defaulted: the assertion is about node
448+
// accounting, and the default 50ms wall clock made it fail on a loaded CI
449+
// runner for machine speed instead. A 1k node cap is far stricter than the
450+
// 50k default — per-character ticking would blow it instantly.
447451
const body = 'a'.repeat(500 * 1024);
448-
const result = parse(`echo "${body}"`);
452+
const result = parse(`echo "${body}"`, { timeoutMs: 10_000, maxNodes: 1_000 });
449453
expect(result.ok).toBe(true);
450454
if (!result.ok) return;
451455
expect(result.hasError).toBe(false);
@@ -454,9 +458,9 @@ describe('adversarial input', () => {
454458
expect(content[0]!.text).toBe(body);
455459
});
456460

457-
it('parses a 500KB heredoc body under the default budget', () => {
461+
it('parses a 500KB heredoc body within the node budget', () => {
458462
const body = 'b'.repeat(500 * 1024);
459-
const result = parse(`cat <<EOF\n${body}\nEOF`);
463+
const result = parse(`cat <<EOF\n${body}\nEOF`, { timeoutMs: 10_000, maxNodes: 1_000 });
460464
expect(result.ok).toBe(true);
461465
if (!result.ok) return;
462466
expect(result.hasError).toBe(false);

0 commit comments

Comments
 (0)