Skip to content

Commit 4bec9b0

Browse files
afujiwara-robloxAiden Fujiwara
andauthored
Modified path to follow symlinks for snapshots tests (#76)
Some snapshot tests were failing on m2 macs due to a difference between "/private/vars/folders..." and "/vars/folders...". "/vars/folders..." seems to just by a symlink to "/private/vars/folders...", so the file path was changed to follow said symlinks on macs only. --------- Co-authored-by: Aiden Fujiwara <[email protected]>
1 parent ed4bdef commit 4bec9b0

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

tests/cli.rs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ use std::{
44
path::{Path, PathBuf},
55
};
66

7+
#[allow(unused_imports)]
8+
use std::fs::canonicalize;
9+
710
use assert_cmd::Command;
811
use insta::assert_snapshot;
912
use tempfile::{tempdir, TempDir};
@@ -34,11 +37,7 @@ impl TestContext {
3437
home_directory.path().display(),
3538
std::path::MAIN_SEPARATOR
3639
);
37-
let working_directory_display = format!(
38-
"{}{}",
39-
working_directory.path().display(),
40-
std::path::MAIN_SEPARATOR
41-
);
40+
let working_directory_display = working_directory_display(&working_directory);
4241
Self {
4342
command,
4443
home_directory,
@@ -103,6 +102,25 @@ impl TestContext {
103102
}
104103
}
105104

105+
#[cfg(not(target_os = "windows"))]
106+
fn working_directory_display(dir: &TempDir) -> String {
107+
format!(
108+
"{}{}",
109+
canonicalize(dir)
110+
.expect(
111+
"
112+
unable to locate working directory",
113+
)
114+
.display(),
115+
std::path::MAIN_SEPARATOR
116+
)
117+
}
118+
119+
#[cfg(target_os = "windows")]
120+
fn working_directory_display(dir: &TempDir) -> String {
121+
format!("{}{}", dir.path().display(), std::path::MAIN_SEPARATOR)
122+
}
123+
106124
fn write_file(path: &Path, content: &str) {
107125
std::fs::write(path, content).expect("unable to write file");
108126
}

0 commit comments

Comments
 (0)