Files
horizon-airdef/third_party/wgpu-hal/src/validation_canary.rs
T
Ludovic Marie 79f78f904b Vendor wgpu-hal 30.0.1 unchanged (examples left out)
The crates.io sources of wgpu-hal 30.0.1, minus its examples, lock file and
VCS metadata, so the next commit can apply one upstream fix that has no
release yet. Excluded from the workspace: it keeps its own lints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 07:22:12 +02:00

41 lines
1.3 KiB
Rust

use alloc::{string::String, vec::Vec};
use parking_lot::Mutex;
/// Stores the text of any validation errors that have occurred since
/// the last call to `get_and_reset`.
///
/// Each value is a validation error and a message associated with it,
/// or `None` if the error has no message from the api.
///
/// This is used for internal wgpu testing only and _must not_ be used
/// as a way to check for errors.
///
/// This works as a static because `cargo nextest` runs all of our
/// tests in separate processes, so each test gets its own canary.
///
/// This prevents the issue of one validation error terminating the
/// entire process.
pub static VALIDATION_CANARY: ValidationCanary = ValidationCanary {
inner: Mutex::new(Vec::new()),
};
/// Flag for internal testing.
#[derive(Debug)]
pub struct ValidationCanary {
inner: Mutex<Vec<String>>,
}
impl ValidationCanary {
#[allow(dead_code, reason = "in some configurations this function is dead")]
pub(crate) fn add(&self, msg: String) {
self.inner.lock().push(msg);
}
/// Returns any API validation errors that have occurred in this process
/// since the last call to this function.
pub fn get_and_reset(&self) -> Vec<String> {
self.inner.lock().drain(..).collect()
}
}