Files
scriptc/packages/compiler/test/wasi-paths.test.ts
Chris Tate c08ab955ae Enforce linting and consistent source formatting
- Enforce oxlint and oxfmt for owned JavaScript and TypeScript with independent CI checks.
- Preserve compiler import boundaries and protected fixtures while cleaning up lint findings.
- Standardize source formatting and validate import, fixture, and embedded-source protections.
2026-10-05 17:51:24 -05:00

32 lines
950 B
TypeScript

import { expect, test } from "vitest";
import { wasiGuestPath } from "../src/wasi-paths.js";
test("WASI guest paths follow the cwd and temp preopens", () => {
expect(wasiGuestPath("/work/repo/tests/main.cjs", "/work/repo", "/host/tmp", "posix")).toBe(
"/tests/main.cjs",
);
expect(wasiGuestPath("/host/tmp/build/main.cjs", "/work/repo", "/host/tmp", "posix")).toBe(
"/tmp/build/main.cjs",
);
expect(wasiGuestPath("/opt/source/main.cjs", "/work/repo", "/host/tmp", "posix")).toBeNull();
});
test("WASI guest paths normalize Windows host separators", () => {
expect(
wasiGuestPath(
"C:\\work\\repo\\tests\\main.cjs",
"C:\\work\\repo",
"C:\\Users\\runner\\Temp",
"win32",
),
).toBe("/tests/main.cjs");
expect(
wasiGuestPath(
"C:\\Users\\runner\\Temp\\build\\main.cjs",
"C:\\work\\repo",
"C:\\Users\\runner\\Temp",
"win32",
),
).toBe("/tmp/build/main.cjs");
});