Skip to content

Commit a33a699

Browse files
committed
remove: remove unused test code
1 parent 1e9e7e6 commit a33a699

File tree

1 file changed

+0
-94
lines changed

1 file changed

+0
-94
lines changed

src/env.rs

-94
Original file line numberDiff line numberDiff line change
@@ -143,100 +143,6 @@ pub fn is_color_available() -> Result<(), ColorError> {
143143
pub(crate) mod tests {
144144
use super::*;
145145
use crate::Color;
146-
use std::collections::HashMap;
147-
use std::sync::Mutex;
148-
use std::sync::OnceLock;
149-
150-
static TEST_ENV: OnceLock<Mutex<TestEnv>> = OnceLock::new();
151-
152-
pub(crate) struct TestEnv {
153-
original_vars: HashMap<String, Option<String>>,
154-
color_vars: Vec<&'static str>,
155-
}
156-
157-
impl TestEnv {
158-
fn new() -> Self {
159-
let color_vars = vec![
160-
"NO_COLOR",
161-
"COLORTERM",
162-
"TERM",
163-
"TERM_PROGRAM",
164-
"CLICOLOR",
165-
"CLICOLOR_FORCE",
166-
"TERMINFO",
167-
"COLORTERM_24BIT",
168-
"KONSOLE_VERSION",
169-
"KITTY_WINDOW_ID",
170-
"ALACRITTY_LOG",
171-
"TMUX",
172-
"ITERM_SESSION_ID",
173-
"WT_SESSION",
174-
"WEZTERM_PANE",
175-
"VTE_VERSION",
176-
];
177-
178-
let original_vars = color_vars
179-
.iter()
180-
.map(|&name| {
181-
let value = env::var(name).ok();
182-
(name.to_string(), value)
183-
})
184-
.collect();
185-
186-
Self {
187-
original_vars,
188-
color_vars,
189-
}
190-
}
191-
192-
fn set_vars(&self, vars: &[(&str, Option<&str>)]) -> Result<(), std::env::VarError> {
193-
// Clear all variables first
194-
for var in &self.color_vars {
195-
env::remove_var(var);
196-
}
197-
198-
// Set new variables
199-
for (name, value) in vars {
200-
match value {
201-
Some(v) => env::set_var(name, v),
202-
None => env::remove_var(name),
203-
}
204-
}
205-
206-
// Verify variables were set correctly
207-
for (name, value) in vars {
208-
match value {
209-
Some(expected) => {
210-
let actual = env::var(name)?;
211-
if actual != *expected {
212-
return Err(std::env::VarError::NotPresent);
213-
}
214-
}
215-
None => {
216-
if env::var(name).is_ok() {
217-
return Err(std::env::VarError::NotPresent);
218-
}
219-
}
220-
}
221-
}
222-
Ok(())
223-
}
224-
225-
fn reset(&self) {
226-
for (name, value) in &self.original_vars {
227-
match value {
228-
Some(v) => env::set_var(name, v),
229-
None => env::remove_var(name),
230-
}
231-
}
232-
}
233-
}
234-
235-
impl Drop for TestEnv {
236-
fn drop(&mut self) {
237-
self.reset();
238-
}
239-
}
240146

241147
pub(crate) fn run_with_env_vars<F, T>(vars: &[(&str, Option<&str>)], test: F) -> T
242148
where

0 commit comments

Comments
 (0)