Skip to content

Align testing API with wgsl-test and add reflection - #7

Merged
claydugo merged 1 commit into
mainfrom
binding-fixtures
Oct 23, 2026
Merged

claydugo merged 1 commit into
mainfrom
binding-fixtures

Conversation

@claydugo

@claydugo claydugo commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Test helpers repeated the compiler settings in their own arguments, and Python tests repeated the shader root and dependencies that the fixtures already know. run_test, run_test_cpu, and the new run_compute now take a Compiler, so the wesl_compiler fixture supplies the modules, filenames, root directory, and dependencies. The native bindings read the same Compiler and add the wgsl_test package themselves. A root can also be a file path relative to the root directory, as in wesl-js testCompute. run_test compiles on each call, as expectWesl does, and replaces prepare_test.

The constants argument fills the virtual constants:: module, as the constants argument of wesl-js link() does, and replaces constant_modules. A str value is a WGSL expression, so a parametrized pytest case can send a vector or an array into one WESL test. The wesl_constants fixture fills the same module, as in wgsl-test. The runner sets no pipeline override values, so an override that a test reads needs a default. The examples move the override logic into public functions that take the value as a parameter, and their tests pass values from constants::.

A test can declare @buffer scratch storage, as in wgsl-test. The runner fills it with zeros and binds it after the result buffer. run_compute follows testCompute: it fills @buffer variables from NumPy values and returns each read_write buffer in the shape of its WGSL type. NumPy is now part of the testing extra. Automatic layouts bind only the resources that the test reaches, so one wesl_resources fixture can serve every test in a directory.

The new wesl.reflect module reads buffer layouts, structure dtypes, and workgroup sizes from WESL declarations, so Python code does not repeat binding numbers and byte sizes. Its names follow wesl-reflect. A size that depends on an override gives None, because its value is unknown until pipeline creation.

The assertion package adds exact i32 and integer vector comparisons, and the tolerance assertions fail on NaN. A failure reports the WGSL type of the compared values. A wgpu error shows each declaration as module::name in place of its mangled name.

Compiler.from_project and the wesl_dependencies fixture load the path dependencies of wesl.toml, and Compiler.compile takes a module path. An unresolved module error names the dependencies or the missing root directory. Collected WESL tests no longer get the gpu marker. Use -m 'not wesl' to deselect them.

Test helpers repeated the compiler settings in their own arguments, and
Python tests repeated the shader root and dependencies that the fixtures
already know. run_test, run_test_cpu, and the new run_compute now take a
Compiler, so the wesl_compiler fixture supplies the modules, filenames,
root directory, and dependencies. The native bindings read the same
Compiler and add the wgsl_test package themselves. A root can also be a
file path relative to the root directory, as in wesl-js testCompute.
run_test compiles on each call, as expectWesl does, and replaces
prepare_test.

The constants argument fills the virtual constants:: module, as the
constants argument of wesl-js link() does, and replaces
constant_modules. A str value is a WGSL expression, so a parametrized
pytest case can send a vector or an array into one WESL test. The
wesl_constants fixture fills the same module, as in wgsl-test. The
runner sets no pipeline override values, so an override that a test
reads needs a default. The examples move the override logic into public
functions that take the value as a parameter, and their tests pass
values from constants::.

A test can declare @buffer scratch storage, as in wgsl-test. The runner
fills it with zeros and binds it after the result buffer. run_compute
follows testCompute: it fills @buffer variables from NumPy values and
returns each read_write buffer in the shape of its WGSL type. NumPy is
now part of the testing extra. Automatic layouts bind only the resources
that the test reaches, so one wesl_resources fixture can serve every
test in a directory.

The new wesl.reflect module reads buffer layouts, structure dtypes, and
workgroup sizes from WESL declarations, so Python code does not repeat
binding numbers and byte sizes. Its names follow wesl-reflect. A size
that depends on an override gives None, because its value is unknown
until pipeline creation.

The assertion package adds exact i32 and integer vector comparisons, and
the tolerance assertions fail on NaN. A failure reports the WGSL type of
the compared values. A wgpu error shows each declaration as module::name
in place of its mangled name.

Compiler.from_project and the wesl_dependencies fixture load the path
dependencies of wesl.toml, and Compiler.compile takes a module path. An
unresolved module error names the dependencies or the missing root
directory. Collected WESL tests no longer get the gpu marker. Use
-m 'not wesl' to deselect them.
@claydugo
claydugo merged commit 3b02898 into main Oct 23, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant