Skip to content

Commit

Permalink
Update test to account for copy's signature change.
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode committed Jul 27, 2020
1 parent 97ef1db commit 403d826
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions tests/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ fn copy_file_does_not_exist() {
let from = Path::new("test/nonexistent-bogus-path");
let to = Path::new("test/other-bogus-path");

match tmpdir.copy(&from, &to) {
match tmpdir.copy(&from, &tmpdir, &to) {
Ok(..) => panic!(),
Err(..) => {
assert!(!tmpdir.exists(from));
Expand All @@ -712,7 +712,7 @@ fn copy_src_does_not_exist() {
let from = Path::new("test/nonexistent-bogus-path");
let to = "out.txt";
check!(check!(tmpdir.create(&to)).write(b"hello"));
assert!(tmpdir.copy(&from, &to).is_err());
assert!(tmpdir.copy(&from, &tmpdir, &to).is_err());
assert!(!tmpdir.exists(from));
let mut v = Vec::new();
check!(check!(tmpdir.open(&to)).read_to_end(&mut v));
Expand All @@ -726,7 +726,7 @@ fn copy_file_ok() {
let out = "out.txt";

check!(check!(tmpdir.create(&input)).write(b"hello"));
check!(tmpdir.copy(&input, &out));
check!(tmpdir.copy(&input, &tmpdir, &out));
let mut v = Vec::new();
check!(check!(tmpdir.open(&out)).read_to_end(&mut v));
assert_eq!(v, b"hello");
Expand All @@ -743,7 +743,7 @@ fn copy_file_dst_dir() {
let out = "out";

check!(tmpdir.create(&out));
match tmpdir.copy(&*out, ".") {
match tmpdir.copy(&*out, &tmpdir, ".") {
Ok(..) => panic!(),
Err(..) => {}
}
Expand All @@ -757,7 +757,7 @@ fn copy_file_dst_exists() {

check!(check!(tmpdir.create(&input)).write("foo".as_bytes()));
check!(check!(tmpdir.create(&output)).write("bar".as_bytes()));
check!(tmpdir.copy(&input, &output));
check!(tmpdir.copy(&input, &tmpdir, &output));

let mut v = Vec::new();
check!(check!(tmpdir.open(&output)).read_to_end(&mut v));
Expand All @@ -769,7 +769,7 @@ fn copy_file_src_dir() {
let tmpdir = tmpdir();
let out = "out";

match tmpdir.copy(".", &out) {
match tmpdir.copy(".", &tmpdir, &out) {
Ok(..) => panic!(),
Err(..) => {}
}
Expand All @@ -786,7 +786,7 @@ fn copy_file_preserves_perm_bits() {
let mut p = attr.permissions();
p.set_readonly(true);
check!(tmpdir.open(&input).and_then(|file| file.set_permissions(p)));
check!(tmpdir.copy(&input, &out));
check!(tmpdir.copy(&input, &tmpdir, &out));
assert!(check!(tmpdir.metadata(out)).permissions().readonly());
check!(tmpdir
.open(&input)
Expand All @@ -801,7 +801,7 @@ fn copy_file_preserves_perm_bits() {
fn copy_file_preserves_streams() {
let tmp = tmpdir();
check!(check!(tmp.create("in.txt:bunny")).write("carrot".as_bytes()));
assert_eq!(check!(tmp.copy("in.txt", "out.txt")), 0);
assert_eq!(check!(tmp.copy("in.txt", &tmp, "out.txt")), 0);
assert_eq!(check!(tmp.metadata("out.txt")).len(), 0);
let mut v = Vec::new();
check!(check!(tmp.open("out.txt:bunny")).read_to_end(&mut v));
Expand All @@ -816,7 +816,7 @@ fn copy_file_returns_metadata_len() {
check!(check!(tmp.create(&in_path)).write(b"lettuce"));
#[cfg(windows)]
check!(check!(tmp.create("in.txt:bunny")).write(b"carrot"));
let copied_len = check!(tmp.copy(&in_path, &out_path));
let copied_len = check!(tmp.copy(&in_path, &tmp, &out_path));
assert_eq!(check!(tmp.metadata(out_path)).len(), copied_len);
}

Expand All @@ -835,7 +835,7 @@ fn copy_file_follows_dst_symlink() {
check!(tmp.write(&out_path, "bar"));
check!(symlink_file(&out_path, &tmp, &out_path_symlink));

check!(tmp.copy(&in_path, &out_path_symlink));
check!(tmp.copy(&in_path, &tmp, &out_path_symlink));

assert!(check!(tmp.symlink_metadata(out_path_symlink))
.file_type()
Expand Down
4 changes: 2 additions & 2 deletions tests/paths-containing-nul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ fn paths_containing_nul() {

assert_invalid_input("rename1", tmpdir.rename("\0", &tmpdir, "a"));
assert_invalid_input("rename2", tmpdir.rename(&dummy_file, &tmpdir, "\0"));
assert_invalid_input("copy1", tmpdir.copy("\0", "a"));
assert_invalid_input("copy2", tmpdir.copy(&dummy_file, "\0"));
assert_invalid_input("copy1", tmpdir.copy("\0", &tmpdir, "a"));
assert_invalid_input("copy2", tmpdir.copy(&dummy_file, &tmpdir, "\0"));
assert_invalid_input("hard_link1", tmpdir.hard_link("\0", &tmpdir, "a"));
assert_invalid_input("hard_link2", tmpdir.hard_link(&dummy_file, &tmpdir, "\0"));
//fixmeassert_invalid_input("soft_link1", tmpdir.soft_link("\0", &tmpdir, "a"));
Expand Down

0 comments on commit 403d826

Please sign in to comment.