test: close the per-file coverage gaps this PR opened

The layered-env reader gained an unreadable-layer path, a default
reporter, and two absent-layer arms with no cases; the credential store
gained two error paths that must not be mistaken for an absent file.

The platform arms and the `linePos` guard cannot be reached from a POSIX
test run — the first is covered by the native Windows job, the second
only satisfies an optional type that `prettyErrors` always fills — so
both carry a v8 ignore naming why.
This commit is contained in:
Yichen Jiang
2026-08-05 13:20:56 +08:00
parent f50b60390c
commit 69d8621e2e
5 changed files with 134 additions and 0 deletions
@@ -101,6 +101,7 @@ const GROUP_OTHER_BITS = 0o077
* @throws when the file exists with group or other permission bits set.
*/
async function assertOwnerOnly(filename: string): Promise<void> {
/* v8 ignore next -- native Windows coverage exercises the skip; POSIX covers the check */
if (process.platform === 'win32') return
let mode: number
try {
@@ -130,6 +131,7 @@ function isENOENT(error: unknown): boolean {
*/
function describeYamlError(error: YAMLError): string {
const at = error.linePos?.[0]
/* v8 ignore next -- `prettyErrors` populates linePos on every error; the guard answers its optional type */
const where = at === undefined ? '' : ` at line ${String(at.line)}, column ${String(at.col)}`
return `${error.code}${where}`
}