Open History to see the last commit
1import * as NodeOS from "node:os";
2import { assert, it } from "vite-plus/test";
3
4import { handleStdioError } from "./stdioErrors.ts";
5
6const errorWithCode = (code: string, errno?: number) =>
7 Object.assign(new Error(code), { code, errno });
8const EDQUOT_ERRNO = NodeOS.constants.errno.EDQUOT;
9
10it.each(["EPIPE", "ENOSPC"])("ignores %s on console output", (code) => {
11 assert.doesNotThrow(() => handleStdioError(errorWithCode(code)));
12});
13
14// Node reports EDQUOT as UNKNOWN because libuv has no name for it.
15it.skipIf(EDQUOT_ERRNO === undefined)("ignores EDQUOT on console output", () => {
16 assert.doesNotThrow(() => handleStdioError(errorWithCode("UNKNOWN", -(EDQUOT_ERRNO ?? 0))));
17});
18
19it("rethrows other console output errors", () => {
20 assert.throws(() => handleStdioError(errorWithCode("EIO")), "EIO");
21 assert.throws(() => handleStdioError(errorWithCode("UNKNOWN", -5)), "UNKNOWN");
22});