Skip to content

Commit 21f3634

Browse files
fix(tests): gate Linux-only env test harness to avoid dead-code on macOS/Windows
CI (nightly + -D warnings) flagged env_lock, EnvGuard, and the Mutex/OnceLock imports as dead code on macOS — the test harness is only used by two tests gated on cfg(target_os = "linux"). Gate the harness and its imports on the same cfg so non-Linux targets are warning-clean. Pre-existing issue; fixing as part of the #7 CI cleanup so my latest commits don't inherit the macOS test failures.
1 parent e6c158f commit 21f3634

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/storage/paths.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,23 +111,33 @@ mod dirs {
111111
#[cfg(test)]
112112
mod tests {
113113
use super::AppPaths;
114+
#[cfg(target_os = "linux")]
114115
use std::path::PathBuf;
116+
#[cfg(target_os = "linux")]
115117
use std::sync::{Mutex, OnceLock};
116118

119+
#[cfg(target_os = "linux")]
117120
use crate::test_utils::TestDir;
118121

122+
// The env-mutation harness (ENV_LOCK, env_lock, EnvGuard) is only used by
123+
// the two Linux-only XDG-override tests below. Gating the harness on the
124+
// same cfg keeps macOS/Windows builds warning-clean under `-D warnings`.
125+
#[cfg(target_os = "linux")]
119126
static ENV_LOCK: OnceLock<Mutex<()>> = OnceLock::new();
120127

128+
#[cfg(target_os = "linux")]
121129
fn env_lock() -> &'static Mutex<()> {
122130
ENV_LOCK.get_or_init(|| Mutex::new(()))
123131
}
124132

133+
#[cfg(target_os = "linux")]
125134
#[allow(unsafe_code)]
126135
struct EnvGuard {
127136
key: &'static str,
128137
prior: Option<String>,
129138
}
130139

140+
#[cfg(target_os = "linux")]
131141
impl EnvGuard {
132142
#[allow(unsafe_code)]
133143
fn set(key: &'static str, value: &PathBuf) -> Self {
@@ -138,6 +148,7 @@ mod tests {
138148
}
139149
}
140150

151+
#[cfg(target_os = "linux")]
141152
impl Drop for EnvGuard {
142153
#[allow(unsafe_code)]
143154
fn drop(&mut self) {

0 commit comments

Comments
 (0)