From 1ad53eff40094783484cd55760c01c8089afa3cf Mon Sep 17 00:00:00 2001 From: bchanot Date: Wed, 4 Nov 2026 13:10:26 +0100 Subject: [PATCH] test(memory): errorish edge cases, letterless rule folded into the filter --- mods/memory/hooks/register.test.ts | 8 +++++++- mods/memory/hooks/register.ts | 6 ++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/mods/memory/hooks/register.test.ts b/mods/memory/hooks/register.test.ts index 6447adc..bdf5c43 100644 --- a/mods/memory/hooks/register.test.ts +++ b/mods/memory/hooks/register.test.ts @@ -285,6 +285,7 @@ test('failureLine: the last line after the first, trailers stripped', () => { expect(failureLine('Exit code 1')).toBeUndefined() expect(failureLine('boom\nfatal: x')).toBeUndefined() expect(failureLine(EXIT1 + '/tmp/a/b 12 deadbeef1')).toBeUndefined() + expect(failureLine(EXIT1 + 'FATAL: disk full')).toBe('FATAL: disk full') }) test('CAP1: a failed command stores one failure with its line', async ( @@ -307,7 +308,7 @@ test('CAP2: Exit code alone stores nothing', async ($, on) => { expect(w.sets).toEqual([]) }) -test('CAP3: excluded texts and a letterless line store nothing', async ( +test('CAP3: excluded texts and a no-error-word line store nothing', async ( $, on, ) => { const w = await boot($, on) @@ -327,6 +328,7 @@ test('CAP11: a last line that is not error-shaped stores nothing', async ( ) => { const w = await boot($, on) await failing($, w, EXIT1 + 'rc=0') + await failing($, w, EXIT1 + 'error x\nrc=0') await failing($, w, EXIT1 + '== before') expect(w.sets).toEqual([]) }) @@ -341,6 +343,10 @@ test('CAP11: error-shaped last lines are stored, line literal', async ( 'https://www.shellcheck.net/wiki/SC2016 -- ' + "Expressions don't expand in singl...", 'doctor.sh: 4 added lines > 80', + 'FATAL: disk full', + "can't open", + 'assertion failed: assert x', + 'permission denied', ] for (const line of lines) await failing($, w, 'Exit code 2\n' + line) expect(failuresOf(w).map(f => f.line)).toEqual(lines) diff --git a/mods/memory/hooks/register.ts b/mods/memory/hooks/register.ts index 93dc3ed..c16c16a 100644 --- a/mods/memory/hooks/register.ts +++ b/mods/memory/hooks/register.ts @@ -128,8 +128,8 @@ const RTK_TRAILER = /** * The line that tells what failed, from an already redacted answer: the * last line after the first of an `Exit code N` text. `undefined` when the - * text is another kind, has no such line, the line holds no letter, or the - * redacted line is not error-shaped (`ERRORISH`); no earlier line is tried. + * text is another kind, has no such line, or the redacted line is not + * error-shaped (`ERRORISH`); no earlier line is tried. */ export function failureLine(text: string): string | undefined { if (!EXIT_CODE.test(text)) return undefined @@ -138,8 +138,6 @@ export function failureLine(text: string): string | undefined { .filter(l => l !== '') if (lines.length < 2) return undefined const line = (lines[lines.length - 1] ?? '').slice(0, MAX_LINE) - const letters = normalize(line).replace(/||#/g, '') - if (!/\p{L}/u.test(letters)) return undefined return ERRORISH.test(line) ? line : undefined }