From 9663028a82aeef9722adaac34d2fcb8c19fc3a53 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Mon, 11 May 2026 16:39:24 +0300 Subject: test: disable real sound playback during checks --- src/sound.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/sound.rs b/src/sound.rs index a156349b..12b127bb 100644 --- a/src/sound.rs +++ b/src/sound.rs @@ -9,6 +9,8 @@ use std::process::{Command, Output}; use tracing::warn; +const DISABLE_SOUND_ENV: &str = "HERDR_DISABLE_SOUND"; + static SOUND_DONE: &[u8] = include_bytes!("../assets/sounds/done.mp3"); static SOUND_REQUEST: &[u8] = include_bytes!("../assets/sounds/request.mp3"); @@ -24,6 +26,10 @@ pub enum Sound { /// Play a notification sound in a background thread. /// Silently does nothing if no audio player is available. pub fn play(sound: Sound, config: &crate::config::SoundConfig) { + if sound_playback_disabled_by_env() { + return; + } + let custom_path = config.path_for(sound); std::thread::spawn(move || { if let Some(path) = custom_path { @@ -46,6 +52,10 @@ pub fn play(sound: Sound, config: &crate::config::SoundConfig) { }); } +fn sound_playback_disabled_by_env() -> bool { + std::env::var_os(DISABLE_SOUND_ENV).is_some() || std::env::var_os("NEXTEST").is_some() +} + fn play_file(path: &Path) -> Result<(), String> { match run_player(path) { Ok(output) if output.status.success() => Ok(()), -- cgit v1.2.3