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..199f00e6315 100644 --- a/cts_runner/tests/integration.rs +++ b/cts_runner/tests/integration.rs @@ -1,4 +1,13 @@ -use std::path::PathBuf; +// Tests for cts_runner +// +// As of June 2025, these tests are not run in CI. + +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 +24,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) })