diff --git a/package-lock.json b/package-lock.json index 04f0b6ca4d..51443f170b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -75,7 +75,8 @@ "node_modules/@bytecodealliance/preview2-shim": { "version": "0.16.5", "resolved": "https://registry.npmjs.org/@bytecodealliance/preview2-shim/-/preview2-shim-0.16.5.tgz", - "integrity": "sha512-1YThPyZ/gWZBgmJ3nEsnBXLxgSV3VOW3vLfyxe/RTKk9fWkTKaUouuZHWBvP0aFN7Hnat733rUeSYAUjEUNONQ==" + "integrity": "sha512-1YThPyZ/gWZBgmJ3nEsnBXLxgSV3VOW3vLfyxe/RTKk9fWkTKaUouuZHWBvP0aFN7Hnat733rUeSYAUjEUNONQ==", + "dev": true }, "node_modules/@esbuild/linux-x64": { "version": "0.21.5", @@ -2100,10 +2101,15 @@ "version": "2.6.2", "license": "MIT", "dependencies": { - "@bytecodealliance/preview2-shim": "^0.16.5", + "@bytecodealliance/preview2-shim": "^0.17.0", "@ruby/wasm-wasi": "^2.0.0" } }, + "packages/npm-packages/ruby-head-wasm-wasip2/node_modules/@bytecodealliance/preview2-shim": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@bytecodealliance/preview2-shim/-/preview2-shim-0.17.0.tgz", + "integrity": "sha512-JorcEwe4ud0x5BS/Ar2aQWOQoFzjq/7jcnxYXCvSMh0oRm0dQXzOA+hqLDBnOMks1LLBA7dmiLLsEBl09Yd6iQ==" + }, "packages/npm-packages/ruby-wasm-emscripten": { "name": "@ruby/wasm-emscripten", "version": "0.1.0", diff --git a/packages/npm-packages/ruby-head-wasm-wasip2/package.json b/packages/npm-packages/ruby-head-wasm-wasip2/package.json index 2f759975af..e2014574c9 100644 --- a/packages/npm-packages/ruby-head-wasm-wasip2/package.json +++ b/packages/npm-packages/ruby-head-wasm-wasip2/package.json @@ -30,9 +30,7 @@ "README.md" ], "scripts": { - "__comment": "FIXME: Enable test:e2e after https://github.com/bytecodealliance/jco/pull/499 is merged", - "test": "npm run run-script -- test:unit && npm run run-script -- test:vitest -- --run", - "run-script": "RUBY_NPM_PACKAGE_ROOT=../ruby-head-wasm-wasip2 ENABLE_COMPONENT_TESTS=1 npm -C ../ruby-wasm-wasi run", + "test": "RUBY_NPM_PACKAGE_ROOT=../ruby-head-wasm-wasip2 ENABLE_COMPONENT_TESTS=1 npm -C ../ruby-wasm-wasi run test:run", "build:deps": "cd ../ruby-wasm-wasi && npm run build", "build:static:files": "../ruby-wasm-wasi/tools/pack-static-files.sh ./dist", "build:static": "npm run build:static:files", @@ -53,6 +51,6 @@ "license": "MIT", "dependencies": { "@ruby/wasm-wasi": "^2.0.0", - "@bytecodealliance/preview2-shim": "^0.16.5" + "@bytecodealliance/preview2-shim": "^0.17.0" } } diff --git a/packages/npm-packages/ruby-wasm-wasi/example/require_relative/index.html b/packages/npm-packages/ruby-wasm-wasi/example/require_relative/index.html index 0c3a20139d..fcd98292fa 100644 --- a/packages/npm-packages/ruby-wasm-wasi/example/require_relative/index.html +++ b/packages/npm-packages/ruby-wasm-wasi/example/require_relative/index.html @@ -21,6 +21,10 @@ end end + # "bundle install --standalone" does not care about bundled gems, so we need + # to activate them manually. + Gem::Dependency.new("csv").to_spec.activate + # The above patch does not break the original require_relative require 'csv' csv = CSV.new "foo\nbar\n" diff --git a/packages/npm-packages/ruby-wasm-wasi/test-e2e/examples/examples.spec.ts b/packages/npm-packages/ruby-wasm-wasi/test-e2e/examples/examples.spec.ts index af6b71059f..362695cd77 100644 --- a/packages/npm-packages/ruby-wasm-wasi/test-e2e/examples/examples.spec.ts +++ b/packages/npm-packages/ruby-wasm-wasi/test-e2e/examples/examples.spec.ts @@ -36,12 +36,14 @@ test.beforeEach(async ({ context, page }) => { }); test("hello.html is healthy", async ({ page }) => { - const messages = []; + const messages: string[] = []; page.on("console", (msg) => messages.push(msg.text())); await page.goto("/hello.html"); await waitForRubyVM(page); - expect(messages[messages.length - 1]).toEqual("Hello, world!\n"); + while (!messages.some((msg) => /Hello, world\!/.test(msg))) { + await page.waitForEvent("console"); + } }); test("lucky.html is healthy", async ({ page }) => { @@ -54,13 +56,12 @@ test("lucky.html is healthy", async ({ page }) => { }); test("script-src/index.html is healthy", async ({ page }) => { - const messages = []; + const messages: string[] = []; page.on("console", (msg) => messages.push(msg.text())); await page.goto("/script-src/index.html"); await waitForRubyVM(page); - const expected = "Hello, world!\n"; - while (messages[messages.length - 1] != expected) { + while (!messages.some((msg) => /Hello, world\!/.test(msg))) { await page.waitForEvent("console"); } }); @@ -79,8 +80,7 @@ if (process.env.RUBY_NPM_PACKAGE_ROOT) { await page.goto("/require_relative/index.html"); await waitForRubyVM(page); - const expected = "Hello, world!\n"; - while (messages[messages.length - 1] != expected) { + while (!messages.some((msg) => /Hello, world\!/.test(msg))) { await page.waitForEvent("console"); } }); diff --git a/packages/npm-packages/ruby-wasm-wasi/test-e2e/integrations/wasi-binding.spec.ts b/packages/npm-packages/ruby-wasm-wasi/test-e2e/integrations/wasi-binding.spec.ts index 634a08cbd7..85c650f94c 100644 --- a/packages/npm-packages/ruby-wasm-wasi/test-e2e/integrations/wasi-binding.spec.ts +++ b/packages/npm-packages/ruby-wasm-wasi/test-e2e/integrations/wasi-binding.spec.ts @@ -18,6 +18,10 @@ if (!process.env.RUBY_NPM_PACKAGE_ROOT) { test.describe('WASI browser binding', () => { test("Read/write on in-memory file system", async ({ page }) => { + test.skip( + process.env.ENABLE_COMPONENT_TESTS != undefined, + "@bytecodealliance/preview2-shim does not allow writing to the file system" + ); const resolve = await resolveBinding(page, "checkResolved"); await page.setContent(` diff --git a/packages/npm-packages/ruby-wasm-wasi/test-e2e/support.ts b/packages/npm-packages/ruby-wasm-wasi/test-e2e/support.ts index 72c13075e0..ff5813968d 100644 --- a/packages/npm-packages/ruby-wasm-wasi/test-e2e/support.ts +++ b/packages/npm-packages/ruby-wasm-wasi/test-e2e/support.ts @@ -19,7 +19,7 @@ export const setupDebugLog = (context: BrowserContext) => { export const setupProxy = (context: BrowserContext) => { const cdnPattern = - /cdn.jsdelivr.net\/npm\/@ruby\/.+-wasm-wasi@.+\/dist\/(.+)/; + /cdn.jsdelivr.net\/npm\/@ruby\/.+@.+\/dist\/(.+)/; context.route(cdnPattern, (route) => { const request = route.request(); console.log(">> [MOCK]", request.method(), request.url());