Skip to content

Commit 7624d3d

Browse files
committed
fix windows test expecations for good (#301)
On windows, there are no symlinks, and we change our expectations accordingly.
1 parent 8d14d2e commit 7624d3d

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

git-worktree/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ thiserror = "1.0.26"
2828
bstr = { version = "0.2.13", default-features = false }
2929

3030
document-features = { version = "0.2.0", optional = true }
31-
symlink = "0.1.0"
3231

3332
[target.'cfg(unix)'.dependencies]
3433
libc = "0.2.119"
3534

3635
[dev-dependencies]
3736
git-testtools = { path = "../tests/tools" }
3837
git-odb = { path = "../git-odb" }
38+
symlink = "0.1.0"
3939

4040
walkdir = "2.3.2"
4141
tempfile = "3.2.0"

git-worktree/src/os.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ pub fn remove_symlink(path: &Path) -> io::Result<()> {
1515
// TODO: use the `symlink` crate once it can delete directory symlinks
1616
#[cfg(windows)]
1717
pub fn remove_symlink(path: &Path) -> io::Result<()> {
18-
dbg!(path, std::fs::symlink_metadata(path), std::fs::metadata(path));
1918
if let Ok(meta) = std::fs::metadata(path) {
2019
if meta.is_file() {
2120
std::fs::remove_file(path) // this removes the link itself

git-worktree/tests/index/checkout.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,10 @@ fn overwriting_files_and_lone_directories_works() {
235235
);
236236

237237
let symlink = destination.path().join("dir/sub-dir/symlink");
238-
assert!(std::fs::symlink_metadata(&symlink).unwrap().is_symlink(),);
238+
assert_eq!(
239+
std::fs::symlink_metadata(&symlink).unwrap().is_symlink(),
240+
opts.fs.symlink
241+
);
239242
assert_eq!(std::fs::read(symlink).unwrap(), b"other content");
240243
}
241244

@@ -290,16 +293,17 @@ fn keep_going_collects_results() {
290293
.iter()
291294
.map(|r| r.path.to_path_lossy().into_owned())
292295
.collect::<Vec<_>>(),
293-
paths(if opts.fs.symlink {
296+
paths(if cfg!(unix) {
294297
["dir/content", "empty"]
295298
} else {
296-
["dir/content", "dir/sub-dir/symlink"] // not actually a symlink anymore
299+
// not actually a symlink anymore, even though symlinks are supported but git think differently.
300+
["dir/content", "dir/sub-dir/symlink"]
297301
})
298302
);
299303

300304
assert_eq!(
301305
stripped_prefix(&destination, &dir_structure(&destination)),
302-
paths(if opts.fs.symlink {
306+
paths(if cfg!(unix) {
303307
["dir/sub-dir/symlink", "executable"]
304308
} else {
305309
["empty", "executable"]

0 commit comments

Comments
 (0)