From f75a1f89c4071dbebedaac3da442af5c7e79241d Mon Sep 17 00:00:00 2001 From: Elijah Morgan Date: Sat, 11 Jan 2025 18:58:25 -0500 Subject: [PATCH] WIP restructure going to try out something different --- bindings/wasm/{ => test-web}/html/index.html | 2 +- .../{ => test-web}/html/limbo-opfs-test.html | 0 .../wasm/{ => test-web}/html/limbo-test.html | 0 bindings/wasm/{ => test-web}/test/helpers.js | 0 .../wasm/{ => test-web}/test/limbo.test.js | 0 .../wasm/{ => test-web}/test/opfs.test.js | 11 ++++--- bindings/wasm/{ => test-web}/test/setup.js | 0 bindings/wasm/test-web/vite.config.js | 29 +++++++++++++++++++ 8 files changed, 35 insertions(+), 7 deletions(-) rename bindings/wasm/{ => test-web}/html/index.html (63%) rename bindings/wasm/{ => test-web}/html/limbo-opfs-test.html (100%) rename bindings/wasm/{ => test-web}/html/limbo-test.html (100%) rename bindings/wasm/{ => test-web}/test/helpers.js (100%) rename bindings/wasm/{ => test-web}/test/limbo.test.js (100%) rename bindings/wasm/{ => test-web}/test/opfs.test.js (94%) rename bindings/wasm/{ => test-web}/test/setup.js (100%) create mode 100644 bindings/wasm/test-web/vite.config.js diff --git a/bindings/wasm/html/index.html b/bindings/wasm/test-web/html/index.html similarity index 63% rename from bindings/wasm/html/index.html rename to bindings/wasm/test-web/html/index.html index 0097d61f8..11a46531d 100644 --- a/bindings/wasm/html/index.html +++ b/bindings/wasm/test-web/html/index.html @@ -2,7 +2,7 @@ diff --git a/bindings/wasm/html/limbo-opfs-test.html b/bindings/wasm/test-web/html/limbo-opfs-test.html similarity index 100% rename from bindings/wasm/html/limbo-opfs-test.html rename to bindings/wasm/test-web/html/limbo-opfs-test.html diff --git a/bindings/wasm/html/limbo-test.html b/bindings/wasm/test-web/html/limbo-test.html similarity index 100% rename from bindings/wasm/html/limbo-test.html rename to bindings/wasm/test-web/html/limbo-test.html diff --git a/bindings/wasm/test/helpers.js b/bindings/wasm/test-web/test/helpers.js similarity index 100% rename from bindings/wasm/test/helpers.js rename to bindings/wasm/test-web/test/helpers.js diff --git a/bindings/wasm/test/limbo.test.js b/bindings/wasm/test-web/test/limbo.test.js similarity index 100% rename from bindings/wasm/test/limbo.test.js rename to bindings/wasm/test-web/test/limbo.test.js diff --git a/bindings/wasm/test/opfs.test.js b/bindings/wasm/test-web/test/opfs.test.js similarity index 94% rename from bindings/wasm/test/opfs.test.js rename to bindings/wasm/test-web/test/opfs.test.js index ea96add44..cdf087ef7 100644 --- a/bindings/wasm/test/opfs.test.js +++ b/bindings/wasm/test-web/test/opfs.test.js @@ -1,6 +1,6 @@ // test/opfs.test.js import { afterAll, beforeAll, beforeEach, expect, test } from "vitest"; -import { setupTestEnvironment, teardownTestEnvironment } from "./helpers"; +import { setupTestEnvironment, teardownTestEnvironment } from "./helpers.js"; let testEnv; @@ -21,7 +21,7 @@ afterAll(async () => { test("basic read/write functionality", async () => { const { page } = testEnv; const result = await page.evaluate(async () => { - const vfs = new window.VFSInterface("/src/opfs-worker.js"); + const vfs = new window.VFSInterface("./opfs-worker.js"); let fd; try { fd = await vfs.open("test.txt", {}); @@ -47,7 +47,7 @@ test("basic read/write functionality", async () => { test("larger data read/write", async () => { const { page } = testEnv; const result = await page.evaluate(async () => { - const vfs = new window.VFSInterface("/src/opfs-worker.js"); + const vfs = new window.VFSInterface("./opfs-worker.js"); let fd; try { fd = await vfs.open("large.txt", {}); @@ -74,7 +74,7 @@ test("larger data read/write", async () => { test("partial reads and writes", async () => { const { page } = testEnv; const result = await page.evaluate(async () => { - const vfs = new window.VFSInterface("/src/opfs-worker.js"); + const vfs = new window.VFSInterface("./opfs-worker.js"); let fd; try { fd = await vfs.open("partial.txt", {}); @@ -113,7 +113,7 @@ test("partial reads and writes", async () => { test("file size operations", async () => { const { page } = testEnv; const result = await page.evaluate(async () => { - const vfs = new window.VFSInterface("/src/opfs-worker.js"); + const vfs = new window.VFSInterface("./opfs-worker.js"); let fd; try { fd = await vfs.open("size.txt", {}); @@ -137,4 +137,3 @@ test("file size operations", async () => { expect(Number(result.size1)).toBe(4); expect(Number(result.size2)).toBe(8); }); - diff --git a/bindings/wasm/test/setup.js b/bindings/wasm/test-web/test/setup.js similarity index 100% rename from bindings/wasm/test/setup.js rename to bindings/wasm/test-web/test/setup.js diff --git a/bindings/wasm/test-web/vite.config.js b/bindings/wasm/test-web/vite.config.js new file mode 100644 index 000000000..d86194560 --- /dev/null +++ b/bindings/wasm/test-web/vite.config.js @@ -0,0 +1,29 @@ +import { defineConfig } from "vite"; +import wasm from "vite-plugin-wasm"; + +export default defineConfig({ + publicDir: "./html", + root: ".", + plugins: [wasm()], + test: { + globals: true, + environment: "happy-dom", + setupFiles: ["./test/setup.js"], + include: ["test/*.test.js"], + }, + server: { + headers: { + "Cross-Origin-Embedder-Policy": "require-corp", + "Cross-Origin-Opener-Policy": "same-origin", + "Cross-Origin-Resource-Policy": "cross-origin", + }, + }, + worker: { + format: "es", + rollupOptions: { + output: { + format: "es", + }, + }, + }, +});