From 165fa2fa1e69da625bb6363edcd4ba485f533ce7 Mon Sep 17 00:00:00 2001 From: Andy Leiserson Date: Mon, 16 Jun 2025 11:46:15 -0700 Subject: [PATCH 1/2] [deno] Don't report support for native-only features Fixes #7796 --- .github/workflows/ci.yml | 10 ++++-- cts_runner/examples/hello-compute.js | 4 +-- cts_runner/tests/features.js | 5 +++ cts_runner/tests/integration.rs | 48 ++++++++++++++++++++++------ deno_webgpu/adapter.rs | 2 ++ 5 files changed, 55 insertions(+), 14 deletions(-) create mode 100644 cts_runner/tests/features.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b676760dca..e9e6f4882ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -742,11 +742,11 @@ jobs: - name: Check for typos uses: crate-ci/typos@v1.33.1 - check-cts-runner: + cts-runner: # runtime is normally 2 minutes timeout-minutes: 10 - name: Clippy cts_runner + name: cts_runner runs-on: ubuntu-latest steps: - name: Checkout repo @@ -773,10 +773,14 @@ jobs: with: key: cts-runner-${{ env.CACHE_SUFFIX }} - - name: Build Deno + - name: Build and Clippy run: | cargo clippy --manifest-path cts_runner/Cargo.toml + - name: Tests + run: | + cargo test --manifest-path cts_runner/Cargo.toml + # Separate job so that new advisories don't block CI. # # This job is not required to pass for PRs to be merged. diff --git a/cts_runner/examples/hello-compute.js b/cts_runner/examples/hello-compute.js index 9c4023ed5e3..a6f6ca400c3 100644 --- a/cts_runner/examples/hello-compute.js +++ b/cts_runner/examples/hello-compute.js @@ -112,8 +112,8 @@ function isTypedArrayEqual(a, b) { const actual = new Uint32Array(data); const expected = new Uint32Array([0, 2, 7, 55]); -console.error("actual", actual); -console.error("expected", expected); +console.log("actual", actual); +console.log("expected", expected); if (!isTypedArrayEqual(actual, expected)) { throw new TypeError("Actual does not equal expected!"); diff --git a/cts_runner/tests/features.js b/cts_runner/tests/features.js new file mode 100644 index 00000000000..23b693a3aa5 --- /dev/null +++ b/cts_runner/tests/features.js @@ -0,0 +1,5 @@ +const adapter = await navigator.gpu.requestAdapter(); + +if (adapter.features.has("mappable-primary-buffers")) { + throw new TypeError("Adapter should not report support for wgpu native-only features"); +} diff --git a/cts_runner/tests/integration.rs b/cts_runner/tests/integration.rs index 30057c3c0a5..0ddb7fbc5e7 100644 --- a/cts_runner/tests/integration.rs +++ b/cts_runner/tests/integration.rs @@ -1,4 +1,9 @@ -use std::path::PathBuf; +use std::{ + fmt::{self, Debug, Display}, + path::PathBuf, + process::Command, + str, +}; pub fn target_dir() -> PathBuf { let current_exe = std::env::current_exe().unwrap(); @@ -15,13 +20,38 @@ pub fn cts_runner_exe_path() -> PathBuf { p } -#[test] -fn hello_compute_example() { - let output = std::process::Command::new(cts_runner_exe_path()) - .arg("examples/hello-compute.js") - .spawn() - .unwrap() - .wait_with_output() +pub struct JsError; + +impl Display for JsError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "JavaScript test returned an error") + } +} + +impl Debug for JsError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self) + } +} + +type JsResult = Result<(), JsError>; + +fn exec_js_test(script: &str) -> JsResult { + let output = Command::new(cts_runner_exe_path()) + .arg(script) + .output() .unwrap(); - assert!(output.status.success()) + println!("{}", str::from_utf8(&output.stdout).unwrap()); + eprintln!("{}", str::from_utf8(&output.stderr).unwrap()); + output.status.success().then_some(()).ok_or(JsError) +} + +#[test] +fn hello_compute_example() -> JsResult { + exec_js_test("examples/hello-compute.js") +} + +#[test] +fn features() -> JsResult { + exec_js_test("tests/features.js") } diff --git a/deno_webgpu/adapter.rs b/deno_webgpu/adapter.rs index d05dca749ab..d5916fb0677 100644 --- a/deno_webgpu/adapter.rs +++ b/deno_webgpu/adapter.rs @@ -84,6 +84,8 @@ impl GPUAdapter { fn features(&self, scope: &mut v8::HandleScope) -> v8::Global { self.features.get(scope, |scope| { let features = self.instance.adapter_features(self.id); + // Only expose WebGPU features, not wgpu native-only features + let features = features & wgpu_types::Features::all_webgpu_mask(); let features = features_to_feature_names(features); GPUSupportedFeatures::new(scope, features) }) From 4f24fdeba7d59c23dd601ecd9e2c50d1e97f9809 Mon Sep 17 00:00:00 2001 From: Andy Leiserson Date: Tue, 17 Jun 2025 12:24:43 -0700 Subject: [PATCH 2/2] Revert the CI changes --- .github/workflows/ci.yml | 10 +++------- cts_runner/tests/integration.rs | 4 ++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e9e6f4882ea..6b676760dca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -742,11 +742,11 @@ jobs: - name: Check for typos uses: crate-ci/typos@v1.33.1 - cts-runner: + check-cts-runner: # runtime is normally 2 minutes timeout-minutes: 10 - name: cts_runner + name: Clippy cts_runner runs-on: ubuntu-latest steps: - name: Checkout repo @@ -773,14 +773,10 @@ jobs: with: key: cts-runner-${{ env.CACHE_SUFFIX }} - - name: Build and Clippy + - name: Build Deno run: | cargo clippy --manifest-path cts_runner/Cargo.toml - - name: Tests - run: | - cargo test --manifest-path cts_runner/Cargo.toml - # Separate job so that new advisories don't block CI. # # This job is not required to pass for PRs to be merged. diff --git a/cts_runner/tests/integration.rs b/cts_runner/tests/integration.rs index 0ddb7fbc5e7..199f00e6315 100644 --- a/cts_runner/tests/integration.rs +++ b/cts_runner/tests/integration.rs @@ -1,3 +1,7 @@ +// Tests for cts_runner +// +// As of June 2025, these tests are not run in CI. + use std::{ fmt::{self, Debug, Display}, path::PathBuf,