refactor: extract did_fill_error_scope test helper from did_fail

This commit is contained in:
Erich Gubler 2025-06-27 12:13:29 -04:00
parent 964c5bbf4c
commit 43eee99b29

View File

@ -90,9 +90,12 @@ pub fn fail_if<T>(
}
}
/// Returns true if the provided callback fails validation.
pub fn did_fail<T>(device: &wgpu::Device, callback: impl FnOnce() -> T) -> (bool, T) {
device.push_error_scope(wgpu::ErrorFilter::Validation);
fn did_fill_error_scope<T>(
device: &wgpu::Device,
callback: impl FnOnce() -> T,
filter: wgpu::ErrorFilter,
) -> (bool, T) {
device.push_error_scope(filter);
let result = callback();
let validation_error = pollster::block_on(device.pop_error_scope());
let failed = validation_error.is_some();
@ -100,6 +103,11 @@ pub fn did_fail<T>(device: &wgpu::Device, callback: impl FnOnce() -> T) -> (bool
(failed, result)
}
/// Returns true if the provided callback fails validation.
pub fn did_fail<T>(device: &wgpu::Device, callback: impl FnOnce() -> T) -> (bool, T) {
did_fill_error_scope(device, callback, wgpu::ErrorFilter::Validation)
}
/// Adds the necessary main function for our gpu test harness.
#[macro_export]
macro_rules! gpu_test_main {