mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Make wgpu_test::valid print errors it detects. (#6136)
* Make `wgpu_test::valid` print errors it detects. When a block passed to `wgpu_test::valid` actually raises validation errors, include the full error in the panic message. --------- Co-authored-by: Erich Gubler <erichdongubler@gmail.com>
This commit is contained in:
parent
5b148f2db6
commit
15d64c362e
@ -54,10 +54,16 @@ pub fn fail<T>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Run some code in an error scope and assert that validation succeeds.
|
/// Run some code in an error scope and assert that validation succeeds.
|
||||||
|
#[track_caller]
|
||||||
pub fn valid<T>(device: &wgpu::Device, callback: impl FnOnce() -> T) -> T {
|
pub fn valid<T>(device: &wgpu::Device, callback: impl FnOnce() -> T) -> T {
|
||||||
device.push_error_scope(wgpu::ErrorFilter::Validation);
|
device.push_error_scope(wgpu::ErrorFilter::Validation);
|
||||||
let result = callback();
|
let result = callback();
|
||||||
assert!(pollster::block_on(device.pop_error_scope()).is_none());
|
if let Some(error) = pollster::block_on(device.pop_error_scope()) {
|
||||||
|
panic!(
|
||||||
|
"`valid` block at {} encountered wgpu error:\n{error}",
|
||||||
|
std::panic::Location::caller()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user