wgsl-test 0.2.16 → 0.2.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -3
- package/bin/wgsl-test +2 -0
- package/dist/index.d.ts +1 -8
- package/dist/index.js +2 -2
- package/dist/runTestCli.js +1 -1
- package/dist/src-OiqlcUu-.js +5946 -0
- package/dist/src-OiqlcUu-.js.map +1 -0
- package/package.json +12 -6
- package/src/TestWesl.ts +4 -1
- package/src/WgslTestRunner.ts +176 -0
- package/src/index.ts +0 -1
- package/src/test/WgslTestRunner.test.ts +33 -0
- package/src/test/fixtures/wesl_test_pkg/shaders/sample.test.wesl +5 -0
- package/src/wgslTestMain.ts +5 -0
- package/dist/src-CGXepQjJ.js +0 -11809
- package/dist/src-CGXepQjJ.js.map +0 -1
- package/src/TestVirtualLib.ts +0 -18
- package/src/test_lib.wesl +0 -89
package/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# wgsl-test
|
|
2
2
|
|
|
3
|
-
Test WGSL and WESL shaders with
|
|
3
|
+
Test WGSL and WESL shaders with the CLI or vitest.
|
|
4
4
|
|
|
5
5
|
- **Native WESL** (`@test`) - Unit test shader functions, assertions run on GPU
|
|
6
|
+
- **CLI** (`wgsl-test run`) - Run tests from the command line
|
|
6
7
|
- **TypeScript-driven** - Integration tests, visual regression, custom validation
|
|
7
8
|
|
|
8
9
|
## Installation
|
|
@@ -27,7 +28,19 @@ fn smootherstepQuarter() {
|
|
|
27
28
|
...
|
|
28
29
|
```
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
### CLI
|
|
32
|
+
|
|
33
|
+
Run tests directly from the command line:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
wgsl-test run # discover **/*.test.wesl, run all
|
|
37
|
+
wgsl-test run path/to/test.wesl # run specific file(s)
|
|
38
|
+
wgsl-test run --projectDir ./foo # specify project root
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Vitest Integration
|
|
42
|
+
|
|
43
|
+
Or run with a minimal TypeScript wrapper:
|
|
31
44
|
|
|
32
45
|
```typescript
|
|
33
46
|
import { getGPUDevice, testWesl } from "wgsl-test";
|
|
@@ -35,7 +48,7 @@ import { getGPUDevice, testWesl } from "wgsl-test";
|
|
|
35
48
|
const device = await getGPUDevice();
|
|
36
49
|
|
|
37
50
|
// runs all tests in interp_test
|
|
38
|
-
await testWesl({ device, moduleName: "interp_test" });
|
|
51
|
+
await testWesl({ device, moduleName: "interp_test" });
|
|
39
52
|
```
|
|
40
53
|
|
|
41
54
|
**[See API.md for assertion functions →](https://github.com/wgsl-tooling-wg/wesl-js/blob/main/tools/packages/wgsl-test/API.md#assertion-functions)**
|
package/bin/wgsl-test
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -209,13 +209,6 @@ declare function testFragment(params: FragmentTestParams): Promise<number[]>;
|
|
|
209
209
|
*/
|
|
210
210
|
declare function testFragmentImage(params: FragmentTestParams): Promise<ImageData$1>;
|
|
211
211
|
//#endregion
|
|
212
|
-
//#region src/TestVirtualLib.d.ts
|
|
213
|
-
/** Size of TestResult struct in bytes.
|
|
214
|
-
* Layout: u32 passed (4) + u32 failCount (4) + padding (8) + vec4f actual (16) + vec4f expected (16) = 48 */
|
|
215
|
-
declare const testResultSize = 48;
|
|
216
|
-
/** Virtual library for test:: namespace providing assertions and result reporting. */
|
|
217
|
-
declare function testVirtualLib(): string;
|
|
218
|
-
//#endregion
|
|
219
212
|
//#region src/TestWesl.d.ts
|
|
220
213
|
/** Parameters for running @test functions in a WESL module. */
|
|
221
214
|
type RunWeslParams = Omit<ComputeTestParams, "resultFormat" | "size" | "dispatchWorkgroups"> & {
|
|
@@ -266,5 +259,5 @@ declare module "vitest" {
|
|
|
266
259
|
}
|
|
267
260
|
}
|
|
268
261
|
//#endregion
|
|
269
|
-
export { CompileShaderParams, ComputeTestParams, DeviceCache, FragmentImageTestParams, FragmentTestParams, type ImageData, type RenderUniforms, ResolveContextParams, RunComputeParams, RunWeslParams, type SamplerOptions, ShaderContext, TestFunctionInfo, TestResult, TestWeslParams, type WgslElementType, checkerboardTexture, colorBarsTexture, compileShader, createProjectResolver, createSampler, createUniformsVirtualLib, destroySharedDevice, edgePatternTexture, expectFragmentImage, expectWesl, findTestFunctions, fullscreenTriangleVertex, getGPU, getGPUAdapter, getGPUDevice, gradientTexture, isDeno, lemurImagePath, lemurTexture, noiseTexture, pngToTexture, radialGradientTexture, renderUniformBuffer, resolveShaderContext, runCompute, runWesl, simpleRender, solidTexture, testCompute, testDisplayName, testFragment, testFragmentImage,
|
|
262
|
+
export { CompileShaderParams, ComputeTestParams, DeviceCache, FragmentImageTestParams, FragmentTestParams, type ImageData, type RenderUniforms, ResolveContextParams, RunComputeParams, RunWeslParams, type SamplerOptions, ShaderContext, TestFunctionInfo, TestResult, TestWeslParams, type WgslElementType, checkerboardTexture, colorBarsTexture, compileShader, createProjectResolver, createSampler, createUniformsVirtualLib, destroySharedDevice, edgePatternTexture, expectFragmentImage, expectWesl, findTestFunctions, fullscreenTriangleVertex, getGPU, getGPUAdapter, getGPUDevice, gradientTexture, isDeno, lemurImagePath, lemurTexture, noiseTexture, pngToTexture, radialGradientTexture, renderUniformBuffer, resolveShaderContext, runCompute, runWesl, simpleRender, solidTexture, testCompute, testDisplayName, testFragment, testFragmentImage, testWesl, updateRenderUniforms, withErrorScopes };
|
|
270
263
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as testCompute, C as testWesl, D as findTestFunctions, E as testFragmentImage, F as createProjectResolver, I as resolveShaderContext, M as lemurTexture, N as pngToTexture, O as testDisplayName, P as compileShader, S as runWesl, T as testFragment, _ as getGPU, a as createUniformsVirtualLib, b as isDeno, c as gradientTexture, d as renderUniformBuffer, f as simpleRender, g as destroySharedDevice, h as withErrorScopes, i as createSampler, j as lemurImagePath, k as runCompute, l as noiseTexture, m as updateRenderUniforms, n as checkerboardTexture, o as edgePatternTexture, p as solidTexture, r as colorBarsTexture, s as fullscreenTriangleVertex, t as DeviceCache, u as radialGradientTexture, v as getGPUAdapter, w as expectFragmentImage, x as expectWesl, y as getGPUDevice } from "./src-OiqlcUu-.js";
|
|
2
2
|
|
|
3
|
-
export { DeviceCache, checkerboardTexture, colorBarsTexture, compileShader, createProjectResolver, createSampler, createUniformsVirtualLib, destroySharedDevice, edgePatternTexture, expectFragmentImage, expectWesl, findTestFunctions, fullscreenTriangleVertex, getGPU, getGPUAdapter, getGPUDevice, gradientTexture, isDeno, lemurImagePath, lemurTexture, noiseTexture, pngToTexture, radialGradientTexture, renderUniformBuffer, resolveShaderContext, runCompute, runWesl, simpleRender, solidTexture, testCompute, testDisplayName, testFragment, testFragmentImage,
|
|
3
|
+
export { DeviceCache, checkerboardTexture, colorBarsTexture, compileShader, createProjectResolver, createSampler, createUniformsVirtualLib, destroySharedDevice, edgePatternTexture, expectFragmentImage, expectWesl, findTestFunctions, fullscreenTriangleVertex, getGPU, getGPUAdapter, getGPUDevice, gradientTexture, isDeno, lemurImagePath, lemurTexture, noiseTexture, pngToTexture, radialGradientTexture, renderUniformBuffer, resolveShaderContext, runCompute, runWesl, simpleRender, solidTexture, testCompute, testDisplayName, testFragment, testFragmentImage, testWesl, updateRenderUniforms, withErrorScopes };
|
package/dist/runTestCli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node --experimental-strip-types
|
|
2
|
-
import { S as runWesl, g as destroySharedDevice, y as getGPUDevice } from "./src-
|
|
2
|
+
import { S as runWesl, g as destroySharedDevice, y as getGPUDevice } from "./src-OiqlcUu-.js";
|
|
3
3
|
|
|
4
4
|
//#region src/runTestCli.ts
|
|
5
5
|
const params = JSON.parse(process.argv[2]);
|