From 07874d74520005e1e8d912665b3ece3f04c848f2 Mon Sep 17 00:00:00 2001 From: Denis Benato Date: Thu, 6 Nov 2025 17:24:01 +0100 Subject: [PATCH] tests: load bundled aura_support.ron when system files missing to make unit tests reliable in CI --- rog-aura/src/aura_detection.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/rog-aura/src/aura_detection.rs b/rog-aura/src/aura_detection.rs index 3f5467c4..ee40af1c 100644 --- a/rog-aura/src/aura_detection.rs +++ b/rog-aura/src/aura_detection.rs @@ -164,7 +164,26 @@ impl LedSupportFile { return Some(data); } - warn!("Does {} exist?", ASUS_LED_MODE_USER_CONF); + // If the system-wide support files were not available (e.g. running + // tests in CI or a development environment) try to load the + // bundled test data shipped with the crate under `data/aura_support.ron`. + // This allows unit tests to run without requiring files to be installed + // to `/usr/share/asusd`. + let mut bundled = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); + bundled.push("data/aura_support.ron"); + if let Ok(buf) = std::fs::read_to_string(&bundled) { + if let Ok(mut tmp) = ron::from_str::(&buf) { + data.0.append(&mut tmp.0); + data.0.sort_by(|a, b| a.device_name.cmp(&b.device_name)); + info!("Loaded bundled LED support data from {}", bundled.display()); + return Some(data); + } else { + warn!("Bundled aura_support.ron present but failed to parse: {}", bundled.display()); + } + } else { + warn!("Does {} exist?", ASUS_LED_MODE_USER_CONF); + } + None } }