From 43eee99b29a0599d0fe57c1a50b906fa5de680f8 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Fri, 27 Jun 2025 12:13:29 -0400 Subject: [PATCH] refactor: extract `did_fill_error_scope` test helper from `did_fail` --- tests/src/lib.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/src/lib.rs b/tests/src/lib.rs index 91b090d39..b15897c92 100644 --- a/tests/src/lib.rs +++ b/tests/src/lib.rs @@ -90,9 +90,12 @@ pub fn fail_if( } } -/// Returns true if the provided callback fails validation. -pub fn did_fail(device: &wgpu::Device, callback: impl FnOnce() -> T) -> (bool, T) { - device.push_error_scope(wgpu::ErrorFilter::Validation); +fn did_fill_error_scope( + 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(device: &wgpu::Device, callback: impl FnOnce() -> T) -> (bool (failed, result) } +/// Returns true if the provided callback fails validation. +pub fn did_fail(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 {