Skip to content

Commit

Permalink
[Tests] Remove dependency on serial_test, use Mutex instead (#341)
Browse files Browse the repository at this point in the history
This enables the use of sanitizers
  • Loading branch information
ilai-deutel authored Nov 18, 2024
1 parent aa31bf9 commit b5dcbf5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 251 deletions.
246 changes: 0 additions & 246 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ winapi-util = "0.1.9"

[dev-dependencies]
tempfile = "3.13.0"
serial_test = "3.2.0"

[badges]
maintenance = { status = "actively-developed" }
Expand Down
10 changes: 6 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ pub fn parse_values<T: FromStr<Err=E>, E: Display>(value: &str) -> Result<Vec<T>
#[cfg(not(target_family = "wasm"))] // No filesystem on wasm
mod tests {
use std::ffi::{OsStr, OsString};
#[cfg(unix)] use std::sync::{LazyLock, Mutex};
use std::{env, fs};

use serial_test::serial;
use tempfile::TempDir;

use super::*;
Expand Down Expand Up @@ -246,10 +246,13 @@ mod tests {
assert_eq!(config, custom_config);
}

#[cfg(unix)]
static XDG_CONFIG_FLAG_LOCK: LazyLock<Mutex<()>> = LazyLock::new(Mutex::default);

#[cfg(unix)]
#[test]
#[serial]
fn xdg_config_home() {
let _lock = XDG_CONFIG_FLAG_LOCK.lock();
let tmp_config_home = TempDir::new().expect("Could not create temporary directory");
test_config_dir(
"XDG_CONFIG_HOME".as_ref(),
Expand All @@ -260,8 +263,8 @@ mod tests {

#[cfg(unix)]
#[test]
#[serial]
fn config_home() {
let _lock = XDG_CONFIG_FLAG_LOCK.lock();
let _temp_env_var = TempEnvVar::new(OsStr::new("XDG_CONFIG_HOME"), None);
let tmp_home = TempDir::new().expect("Could not create temporary directory");
test_config_dir(
Expand All @@ -273,7 +276,6 @@ mod tests {

#[cfg(windows)]
#[test]
#[serial]
fn app_data() {
let tmp_home = TempDir::new().expect("Could not create temporary directory");
test_config_dir(
Expand Down

0 comments on commit b5dcbf5

Please sign in to comment.