Bake on the CPU under coverage so the Sonar shards stop crashing at exit (#840)

Merged under Skylar's explicit override (Nightly 792) after green CI, CodeRabbit on this head with no open threads, and an independent adversarial review with no blockers.
This commit is contained in:
skylar taylor-barrick authored and GitHub committed 2026-11-25 20:02:16 -06:00
1 parent bbd680686e
commit dc2c80739b
2 files changed
+14 -1

No files matched your search

+3
View File
@@ -104,6 +104,9 @@ egui-phosphor = { path = "vendor/egui-phosphor" }
[workspace.lints.rust]
unsafe_code = "forbid"
# cargo-llvm-cov always sets `cfg(coverage)`: a coverage build bakes on the CPU (texturecraft-engine
# picks no GPU tracer there) and the cfg would otherwise trip unexpected_cfgs under -D warnings.
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage)'] }
[workspace.lints.clippy]
dbg_macro = "warn"
+11 -1
View File
@@ -93,6 +93,14 @@ pub fn set_gpu_raytracing(enabled: bool) {
/// The tracer a bake starting now uses: the installed one while GPU raytracing is on, else none (the CPU)
fn chosen_tracer(installed: Option<&Arc<dyn Tracer>>, enabled: bool) -> Option<Arc<dyn Tracer>> {
// The coverage build bakes on the CPU, the fallback every GPU failure takes anyway. Its tests run on
// a headless runner, and the bake's GPU device is created on a worker thread there: tearing that
// GL context down crashes the test process at exit (a wgpu-hal GLES `BadDisplay` panic, or a
// SIGSEGV in the driver), which took a different test down on every run. The compute shaders are
// never line-covered, so nothing is lost.
if cfg!(coverage) {
return None;
}
installed.filter(|_| enabled).cloned()
}
@@ -917,7 +925,9 @@ mod gpu_raytracing_tests {
fn bakes_use_the_installed_gpu_tracer_only_while_gpu_raytracing_is_on() {
let installed: Arc<dyn Tracer> = Arc::new(NamedTracer);
assert_eq!(chosen_tracer(Some(&installed), true).map(|tracer| tracer.name()), Some("gpu".to_string()));
// A coverage build keeps every bake on the CPU: its headless runner has no GPU to bake on
let gpu = (!cfg!(coverage)).then(|| "gpu".to_string());
assert_eq!(chosen_tracer(Some(&installed), true).map(|tracer| tracer.name()), gpu, "on casts the rays on the GPU");
assert!(chosen_tracer(Some(&installed), false).is_none(), "off keeps the rays on the CPU");
assert!(chosen_tracer(None, true).is_none(), "no installed tracer bakes on the CPU");
}