1/**
2 * The suite on desktop WebGPU (Google Dawn), against the real pipeline:
3 * SceneSpec -> generated MATLAB -> numbl lowering -> generated WGSL -> GPU.
4 *
5 * Run through vite-node, which is what resolves numbl's compiler sources and
6 * the `?raw` .m imports:
7 *
8 * npm run test:node
9 */
10import { installWebGpu, errMsg, NO_ADAPTER_HINT } from './nodeWebGpu.ts';
11import { requestAcousticDevice } from '../src/device.ts';
12import {
13 planChecks,
14 codegenChecks,
15 sceneFileChecks,
16 stringChecks,
17 barChecks,
18 membraneChecks,
19 wallChecks,
20 duetChecks,
21 placementChecks,
22 spectrumChecks,
23 splitChecks,
24 modalChecks,
25} from '../test/checks.ts';
27let failures = 0;
28const check = (name: string, ok: boolean, detail: string): void => {
29 console.log(`${ok ? 'PASS' : 'FAIL'} ${name} — ${detail}`);
30 if (!ok) failures++;
31};
32const log = (s: string): void => console.log(s);
34/**
35 * These checks compile MATLAB to compute shaders, so they need a GPU.
36 * `--skip-without-gpu` lets a runner that has none say so and move on; a plain
37 * local run still fails loudly, so a missing GPU is never mistaken for a pass.
38 */
39const skipWithoutGpu = process.argv.includes('--skip-without-gpu');
41let runtime: string;
42let device: GPUDevice;
43try {
44 runtime = await installWebGpu();
45 device = await requestAcousticDevice();
46} catch (e) {
47 const detail = `${errMsg(e)}\n${NO_ADAPTER_HINT}`;
48 if (skipWithoutGpu) {
49 console.log(`SKIP no WebGPU available here, so these checks did not run.\n${detail}`);
50 process.exit(0);
51 }
52 console.error(`test-node: ${detail}`);
53 process.exit(1);
54}
55console.log(`soundbox tests — ${runtime}\n`);
57await planChecks(device, check, log);
58await codegenChecks(device, check, log);
59await sceneFileChecks(device, check, log);
60await stringChecks(device, check, log);
61await barChecks(device, check, log);
62await membraneChecks(device, check, log);
63await wallChecks(device, check, log);
64await duetChecks(device, check, log);
65await placementChecks(device, check, log);
66await spectrumChecks(device, check, log);
67await splitChecks(device, check, log);
68await modalChecks(device, check, log);
70console.log(failures ? `\n${failures} failure(s)` : '\nall checks passed');
71process.exit(failures ? 1 : 0);