/** * The shared correctness suite on desktop WebGPU (Dawn). Run: npm run test:node * * `--skip-without-gpu` exits 0 when no adapter exists (CI runners without a * GPU for Node; the browser suite still covers everything on SwiftShader). */ import { installWebGpu, errMsg, NO_ADAPTER_HINT } from './nodeWebGpu.ts'; import { runCases } from '../test/cases.ts'; async function main(): Promise { const skipWithoutGpu = process.argv.includes('--skip-without-gpu'); try { console.log(await installWebGpu()); } catch (e) { console.error(errMsg(e)); process.exit(skipWithoutGpu ? 0 : 1); } const adapter = await navigator.gpu.requestAdapter(); if (!adapter) { console.error('no WebGPU adapter\n' + NO_ADAPTER_HINT); process.exit(skipWithoutGpu ? 0 : 1); } const device = await adapter.requestDevice({ requiredLimits: { maxStorageBufferBindingSize: adapter.limits.maxStorageBufferBindingSize, maxBufferSize: adapter.limits.maxBufferSize, maxStorageBuffersPerShaderStage: adapter.limits.maxStorageBuffersPerShaderStage, }, }); const failures = await runCases(device, (line) => console.log(line)); console.log(failures ? `\n${failures} failure(s)` : '\nall tests passed'); process.exit(failures ? 1 : 0); } main().catch((e) => { console.error(e); process.exit(1); });