Fix tests for windows paths (#1153)

pull/1131/merge
Peter Weston 2024-11-13 20:08:24 +00:00 committed by GitHub
parent 613cfad233
commit b532b9e3f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 13 additions and 7 deletions

View File

@ -6,6 +6,7 @@ import { assertEquals } from "@std/assert";
import { dirname, join } from "@std/path";
import { MemoryKvPrimitives } from "$lib/data/memory_kv_primitives.ts";
import { runPlug } from "../plug_run.ts";
import { fileURLToPath } from "node:url";
Deno.test("Test plug run", {
sanitizeResources: false,
@ -13,7 +14,7 @@ Deno.test("Test plug run", {
}, async () => {
const assetBundle = new AssetBundle(assets);
const testFolder = dirname(new URL(import.meta.url).pathname);
const testFolder = dirname(fileURLToPath(new URL(import.meta.url)));
const testSpaceFolder = join(testFolder, "test_space");
const plugFolder = join(testSpaceFolder, "_plug");
@ -27,7 +28,7 @@ Deno.test("Test plug run", {
join(testFolder, "test_plug_run.plug.yaml"),
plugFolder,
{
configPath: new URL("../../deno.json", import.meta.url).pathname,
configPath: fileURLToPath(new URL("../../deno.json", import.meta.url)),
},
);
assertEquals(

View File

@ -4,6 +4,7 @@ import { assertEquals } from "@std/assert";
import { compileManifest } from "../compile.ts";
import * as esbuild from "esbuild";
import type { SysCallMapping } from "../../lib/plugos/system.ts";
import { fileURLToPath } from "node:url";
Deno.test("Run a deno sandbox", {
sanitizeResources: false,
@ -32,10 +33,10 @@ Deno.test("Run a deno sandbox", {
const tempDir = await Deno.makeTempDir();
const workerPath = await compileManifest(
new URL("test_runtime.plug.yaml", import.meta.url).pathname,
fileURLToPath(new URL("test_runtime.plug.yaml", import.meta.url)),
tempDir,
{
configPath: new URL("../../deno.json", import.meta.url).pathname,
configPath: fileURLToPath(new URL("../../deno.json", import.meta.url)),
},
);

View File

@ -3,10 +3,12 @@ import { luaBuildStandardEnv } from "$common/space_lua/stdlib.ts";
import { LuaEnv, LuaStackFrame } from "$common/space_lua/runtime.ts";
import { evalStatement } from "$common/space_lua/eval.ts";
import { assert } from "@std/assert/assert";
import { fileURLToPath } from "node:url";
Deno.test("Lua language tests", async () => {
// Read the Lua file
const luaFile = await Deno.readTextFile(
new URL("./language_test.lua", import.meta.url).pathname,
fileURLToPath(new URL("./language_test.lua", import.meta.url)),
);
const chunk = parse(luaFile, {});
const env = new LuaEnv(luaBuildStandardEnv());

View File

@ -2,10 +2,11 @@ import type { FileMeta } from "../../../plug-api/types.ts";
import { assert } from "@std/assert";
import fileSystemSyscalls from "./fs.deno.ts";
import { dirname, resolve } from "@std/path";
import { fileURLToPath } from "node:url";
Deno.test("Test FS operations", async () => {
const thisFolder = resolve(
dirname(new URL(import.meta.url).pathname),
dirname(fileURLToPath(new URL(import.meta.url))),
);
const syscalls = fileSystemSyscalls(thisFolder);
const allFiles: FileMeta[] = await syscalls["fs.listFiles"](

View File

@ -5,6 +5,7 @@ import { createSandbox } from "../../lib/plugos/sandboxes/deno_worker_sandbox.ts
import { renderMarkdownToHtml } from "./markdown_render.ts";
import { extendedMarkdownLanguage } from "$common/markdown_parser/parser.ts";
import { assertEquals } from "@std/assert";
import { fileURLToPath } from "node:url";
Deno.test("Markdown render", async () => {
const system = new System<any>("server");
@ -21,7 +22,7 @@ Deno.test("Markdown render", async () => {
),
);
const testFile = Deno.readTextFileSync(
new URL("test/example.md", import.meta.url).pathname,
fileURLToPath(new URL("test/example.md", import.meta.url)),
);
const tree = parse(extendedMarkdownLanguage, testFile);
renderMarkdownToHtml(tree, {