Skip to content

Commit 248907d

Browse files
authored
Fix test for Windows upgrade check. (#2477)
1 parent 60f7458 commit 248907d

4 files changed

Lines changed: 11 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/soroban-cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,4 @@ assert_fs = "1.0.7"
141141
predicates = { workspace = true }
142142
walkdir = "2.5.0"
143143
mockito = "1.5.0"
144+
serial_test = "3.0.0"

cmd/soroban-cli/src/config/data.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,10 @@ fn to_xdr(data: &impl WriteXdr) -> Result<String, xdr::Error> {
202202
#[cfg(test)]
203203
mod test {
204204
use super::*;
205+
use serial_test::serial;
205206

206207
#[test]
208+
#[serial]
207209
fn test_write_read() {
208210
let t = assert_fs::TempDir::new().unwrap();
209211
std::env::set_var("STELLAR_DATA_HOME", t.path().to_str().unwrap());

cmd/soroban-cli/src/config/upgrade_check.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,18 @@ impl UpgradeCheck {
6969
#[cfg(test)]
7070
mod tests {
7171
use super::*;
72+
use serial_test::serial;
7273
use std::env;
7374

7475
#[test]
76+
#[serial]
7577
fn test_upgrade_check_load_save() {
76-
// Set the `XDG_DATA_HOME` environment variable to a temporary directory
78+
// Use `STELLAR_DATA_HOME` (cross-platform, highest priority) so that
79+
// any `STELLAR_DATA_HOME` or `XDG_DATA_HOME` leaked by parallel tests
80+
// cannot shadow our temp dir.
7781
let temp_dir = tempfile::tempdir().unwrap();
78-
env::set_var("XDG_DATA_HOME", temp_dir.path());
82+
env::remove_var("XDG_DATA_HOME");
83+
env::set_var("STELLAR_DATA_HOME", temp_dir.path());
7984
// Test default loading
8085
let default_check = UpgradeCheck::load().unwrap();
8186
assert_eq!(default_check, UpgradeCheck::default());

0 commit comments

Comments
 (0)