test(memory): errorish edge cases, letterless rule folded into the filter
This commit is contained in:
1 parent
19d063525b
commit
1ad53eff40
2 files changed
+9
-5
No files matched your search
@@ -285,6 +285,7 @@ test('failureLine: the last line after the first, trailers stripped', () => {
|
|||||||
expect(failureLine('Exit code 1')).toBeUndefined()
|
expect(failureLine('Exit code 1')).toBeUndefined()
|
||||||
expect(failureLine('boom\nfatal: x')).toBeUndefined()
|
expect(failureLine('boom\nfatal: x')).toBeUndefined()
|
||||||
expect(failureLine(EXIT1 + '/tmp/a/b 12 deadbeef1')).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 (
|
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([])
|
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,
|
$, on,
|
||||||
) => {
|
) => {
|
||||||
const w = await boot($, 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)
|
const w = await boot($, on)
|
||||||
await failing($, w, EXIT1 + 'rc=0')
|
await failing($, w, EXIT1 + 'rc=0')
|
||||||
|
await failing($, w, EXIT1 + 'error x\nrc=0')
|
||||||
await failing($, w, EXIT1 + '== before')
|
await failing($, w, EXIT1 + '== before')
|
||||||
expect(w.sets).toEqual([])
|
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 -- ' +
|
'https://www.shellcheck.net/wiki/SC2016 -- ' +
|
||||||
"Expressions don't expand in singl...",
|
"Expressions don't expand in singl...",
|
||||||
'doctor.sh: 4 added lines > 80',
|
'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)
|
for (const line of lines) await failing($, w, 'Exit code 2\n' + line)
|
||||||
expect(failuresOf(w).map(f => f.line)).toEqual(lines)
|
expect(failuresOf(w).map(f => f.line)).toEqual(lines)
|
||||||
|
|||||||
@@ -128,8 +128,8 @@ const RTK_TRAILER =
|
|||||||
/**
|
/**
|
||||||
* The line that tells what failed, from an already redacted answer: the
|
* 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
|
* 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
|
* text is another kind, has no such line, or the redacted line is not
|
||||||
* redacted line is not error-shaped (`ERRORISH`); no earlier line is tried.
|
* error-shaped (`ERRORISH`); no earlier line is tried.
|
||||||
*/
|
*/
|
||||||
export function failureLine(text: string): string | undefined {
|
export function failureLine(text: string): string | undefined {
|
||||||
if (!EXIT_CODE.test(text)) return undefined
|
if (!EXIT_CODE.test(text)) return undefined
|
||||||
@@ -138,8 +138,6 @@ export function failureLine(text: string): string | undefined {
|
|||||||
.filter(l => l !== '')
|
.filter(l => l !== '')
|
||||||
if (lines.length < 2) return undefined
|
if (lines.length < 2) return undefined
|
||||||
const line = (lines[lines.length - 1] ?? '').slice(0, MAX_LINE)
|
const line = (lines[lines.length - 1] ?? '').slice(0, MAX_LINE)
|
||||||
const letters = normalize(line).replace(/<path>|<hex>|#/g, '')
|
|
||||||
if (!/\p{L}/u.test(letters)) return undefined
|
|
||||||
return ERRORISH.test(line) ? line : undefined
|
return ERRORISH.test(line) ? line : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user