Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deno 2.x can't run the test suite #4123

Open
turbocrime opened this issue Dec 28, 2024 · 1 comment
Open

Deno 2.x can't run the test suite #4123

turbocrime opened this issue Dec 28, 2024 · 1 comment

Comments

@turbocrime
Copy link

turbocrime commented Dec 28, 2024

trying to use this test suite to validate some changes i'm making to gfx-rs/wgpu which uses deno to run the suite. that repo references quite an old cts revision. using a more modern version of the suite, with tests for the features i'm interested in, breaks their cts_runner tool.

but, the failure is the same between their cts_runner, and also manual execution with the latest stable deno release v2.1.4 on tip of gpuweb/cts@main.

problem

it seems like deno can no longer run this test suite.

investigating

using cts_runner

using wgpu's cts_runner with an updated cts revision results in this failure:

error: Relative import path "fs" not prefixed with / or ./ or ../ from "file:///Users/yet/Developer/github.com/gfx-rs/wgpu/cts/out/common/runtime/cmdline.js"

correct node:fs import

it seems like deno is mistaking the node fs module for a local module path. looking at deno documentation, it seems that importing a node module now requires a node-protocol prefix. updating the import to node:fs doesn't actually fix anything

error: Provided module specifier "node:fs" is not a file URL.

this is strange, because deno is documented to support this module. i couldn't find any discussion of an error like this.

without cts_runner

i wonder if it's something to do with wgpu's specific runner setup, so i simply try calling the run_deno script,

executing ./tools/run_deno directly without updated import

seems to match the cts_runner failure

⚠️  The `--unstable` flag has been removed in Deno 2.0. Use granular `--unstable-*` flags instead.
Learn more at: https://docs.deno.com/runtime/manual/tools/unstable_flags
error: Relative import path "fs" not prefixed with / or ./ or ../
  hint: If you want to use a built-in Node module, add a "node:" prefix (ex. "node:fs").
    at file:///Users/yet/Developer/github.com/gfx-rs/wgpu/cts/out/common/runtime/cmdline.js:3:24

executing ./tools/run_deno directly with updated node:fs import

⚠️  The `--unstable` flag has been removed in Deno 2.0. Use granular `--unstable-*` flags instead.
Learn more at: https://docs.deno.com/runtime/manual/tools/unstable_flags
error: Uncaught (in promise) ReferenceError: require is not defined
  const { existsSync } = require('fs');
                         ^
    at node (file:///Users/yet/Developer/github.com/gfx-rs/wgpu/cts/out/common/runtime/helper/sys.js:6:26)
    at file:///Users/yet/Developer/github.com/gfx-rs/wgpu/cts/out/common/runtime/helper/sys.js:45:57

    info: Deno supports CommonJS modules in .cjs files, or when the closest
          package.json has a "type": "commonjs" option.
    hint: Rewrite this module to ESM,
          or change the file extension to .cjs,
          or add package.json next to the file with "type": "commonjs" option,
          or pass --unstable-detect-cjs flag to detect CommonJS when loading.
    docs: https://docs.deno.com/go/commonjs

according to documentation, deno should support use of node's fs module, and it's unclear why this doesn't work.

i suspect it might have something to do with the command-line flags on the tools/run_deno script, which are apparently out of date (issue soon).

workaround already present

at this point i noticed that a workaround seems to already exist within cmdline.ts.

all node modules are accessed via helper/sys.ts

https://github.com/gpuweb/cts/blob/main/src/common/runtime/helper/sys.ts

suspected cause

other node utilities are accessed via the helper/sys module, and the section of code directly using fs.readFile was added later. this seems inconsistent.

ea0cfeb#diff-fe71a942bd25eff623744571b92fff7fe320776150c5accb817c01d442dd110e

correcting this (pr soon) does allow the test suite to execute with deno.

@turbocrime turbocrime changed the title Deno can't run the test suite Deno 2.x can't run the test suite Dec 29, 2024
@kainino0x
Copy link
Collaborator

Thanks for the report and investigation! We (the core group of WebGPU people, who work on the browsers) are not working on maintaining Deno support at all, but it's great to have it working. Will be glad to take a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants