Skip to content

Commit

Permalink
Add more tests, and disable some tests on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode committed Sep 21, 2024
1 parent db8708c commit 561f49e
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/fs_additional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,10 @@ fn dotdot_in_middle_of_symlink() {
}

/// Same as `dotdot_in_middle_of_symlink`, but use two levels of `..`.
///
/// This fails on Windows for unknown reasons. Patches welcome.
#[test]
#[cfg(not(windows))]
fn dotdot_more_in_middle_of_symlink() {
let tmpdir = tmpdir();

Expand All @@ -1076,6 +1079,28 @@ fn dotdot_more_in_middle_of_symlink() {
assert_eq!(data, foo);
}

/// Same as `dotdot_more_in_middle_of_symlink`, but the symlink doesn't
/// include `c`.
///
/// This fails on Windows for unknown reasons. Patches welcome.
#[test]
#[cfg(not(windows))]
fn dotdot_other_in_middle_of_symlink() {
let tmpdir = tmpdir();

let foo = b"foo";
check!(tmpdir.write("target", foo));
check!(tmpdir.create_dir_all("b/c"));
let c = check!(tmpdir.open_dir("b/c"));
check!(symlink_dir("../..", &c, "up"));

let path = "b/c/up/target";
let mut file = check!(tmpdir.open(path));
let mut data = Vec::new();
check!(file.read_to_end(&mut data));
assert_eq!(data, foo);
}

/// Same as `dotdot_more_in_middle_of_symlink`, but use a symlink that
/// doesn't end with `..`.
#[test]
Expand All @@ -1095,6 +1120,25 @@ fn dotdot_even_more_in_middle_of_symlink() {
assert_eq!(data, foo);
}

/// Same as `dotdot_even_more_in_middle_of_symlink`, but the symlink doesn't
/// include `c`.
#[test]
fn dotdot_even_other_in_middle_of_symlink() {
let tmpdir = tmpdir();

let foo = b"foo";
check!(tmpdir.create_dir_all("b/c"));
check!(tmpdir.write("b/target", foo));
let c = check!(tmpdir.open_dir("b/c"));
check!(symlink_dir("../../b", &c, "up"));

let path = "b/c/up/target";
let mut file = check!(tmpdir.open(path));
let mut data = Vec::new();
check!(file.read_to_end(&mut data));
assert_eq!(data, foo);
}

/// Similar to `dotdot_in_middle_of_symlink`, but this time the symlink to
/// `..` does happen to be the end of the path, so we need to make sure
/// the implementation doesn't just do a stack pop when it sees the `..`
Expand Down

0 comments on commit 561f49e

Please sign in to comment.