summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcyqsimon <28627918+cyqsimon@users.noreply.github.com>2023-03-02 17:39:15 +0800
committerGitHub <noreply@github.com>2023-03-02 09:39:15 +0000
commita0338905064c0df7be229887aeaff59c2c3251e4 (patch)
tree1df5f353aee0e2b465e2cd32fd115d395def4350
parente6ff0514301fcebeaccd8a8e9b5fedc4bded220b (diff)
Fix race condition in directory tests (#748)
-rw-r--r--atuin-common/src/utils.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/atuin-common/src/utils.rs b/atuin-common/src/utils.rs
index 59545a26..a73e3fba 100644
--- a/atuin-common/src/utils.rs
+++ b/atuin-common/src/utils.rs
@@ -50,6 +50,14 @@ mod tests {
use std::env;
#[test]
+ fn test_dirs() {
+ // these tests need to be run sequentially to prevent race condition
+ test_config_dir_xdg();
+ test_config_dir();
+ test_data_dir_xdg();
+ test_data_dir();
+ }
+
fn test_config_dir_xdg() {
env::remove_var("HOME");
env::set_var("XDG_CONFIG_HOME", "/home/user/custom_config");
@@ -60,7 +68,6 @@ mod tests {
env::remove_var("XDG_CONFIG_HOME");
}
- #[test]
fn test_config_dir() {
env::set_var("HOME", "/home/user");
env::remove_var("XDG_CONFIG_HOME");
@@ -68,7 +75,6 @@ mod tests {
env::remove_var("HOME");
}
- #[test]
fn test_data_dir_xdg() {
env::remove_var("HOME");
env::set_var("XDG_DATA_HOME", "/home/user/custom_data");
@@ -76,7 +82,6 @@ mod tests {
env::remove_var("XDG_DATA_HOME");
}
- #[test]
fn test_data_dir() {
env::set_var("HOME", "/home/user");
env::remove_var("XDG_DATA_HOME");