#![allow(clippy::needless_range_loop)]
use vyre_driver_wgpu::WgpuBackend;
#[test]
fn successful_acquisition_means_non_cpu_adapter() {
let backend = WgpuBackend::acquire().expect(
"WgpuBackend::acquire failed on a machine that must have a GPU. \
Fix: inspect driver visibility and adapter probing; this must not silently skip.",
);
let info = backend.adapter_info();
assert!(
!matches!(info.device_type, wgpu::DeviceType::Cpu | wgpu::DeviceType::Other),
"Fix: WgpuBackend must never silently fall back to a CPU adapter on a machine with GPU support. \
Adapter `{}` has type {:?}.",
info.name,
info.device_type
);
}
#[test]
fn default_acquisition_prefers_discrete_gpu_when_enumerable() {
let backend = WgpuBackend::acquire().expect(
"WgpuBackend::acquire failed on a machine that must have a GPU. \
Fix: inspect driver visibility and adapter probing; this must not silently skip.",
);
let adapters = vyre_driver_wgpu::runtime::device::enumerate_adapters();
let has_discrete = adapters
.iter()
.any(|adapter| adapter.device_type == wgpu::DeviceType::DiscreteGpu);
if has_discrete {
assert_eq!(
backend.adapter_info().device_type,
wgpu::DeviceType::DiscreteGpu,
"Fix: default WgpuBackend acquisition must prefer an enumerable discrete GPU over CPU/integrated adapters."
);
}
}
#[test]
fn backend_error_on_missing_gpu_is_actionable() {
if let Err(e) = WgpuBackend::acquire() {
let msg = e.to_string();
assert!(
msg.contains("Fix:"),
"Fix: headless backend error must be actionable, got: {msg}"
);
assert!(
msg.contains("adapter") || msg.contains("GPU") || msg.contains("driver"),
"Fix: headless error must mention adapters, GPU, or driver so the user knows where to look, got: {msg}"
);
}
}
#[test]
fn backend_error_lists_probed_adapters() {
if let Err(e) = WgpuBackend::acquire() {
let msg = e.to_string();
assert!(
msg.contains("Probed adapters") || msg.contains("no compatible GPU adapter"),
"Fix: backend error should list probed adapters or clearly state none were found, got: {msg}"
);
}
}