Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cp: remove unnecessary calls of touch() in tests #6263

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 5 additions & 23 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2606,10 +2606,8 @@ fn test_copy_through_just_created_symlink() {
at.mkdir("b");
at.mkdir("c");
at.relative_symlink_file("../t", "a/1");
at.touch("b/1");
at.write("b/1", "hello");
if create_t {
at.touch("t");
at.write("t", "world");
}
ucmd.arg("--no-dereference")
Expand Down Expand Up @@ -2839,7 +2837,6 @@ fn test_copy_no_dereference_1() {
let (at, mut ucmd) = at_and_ucmd!();
at.mkdir("a");
at.mkdir("b");
at.touch("a/foo");
at.write("a/foo", "bar");
at.relative_symlink_file("../a/foo", "b/foo");
ucmd.args(&["-P", "a/foo", "b"]).fails();
Expand All @@ -2852,10 +2849,8 @@ fn test_abuse_existing() {
at.mkdir("b");
at.mkdir("c");
at.relative_symlink_file("../t", "a/1");
at.touch("b/1");
at.write("b/1", "hello");
at.relative_symlink_file("../t", "c/1");
at.touch("t");
at.write("t", "i");
ucmd.args(&["-dR", "a/1", "b/1", "c"])
.fails()
Expand Down Expand Up @@ -2967,7 +2962,6 @@ fn test_cp_copy_symlink_contents_recursive() {
let (at, mut ucmd) = at_and_ucmd!();
at.mkdir("src-dir");
at.mkdir("dest-dir");
at.touch("f");
at.write("f", "f");
at.relative_symlink_file("f", "slink");
at.relative_symlink_file("no-file", &path_concat!("src-dir", "slink"));
Expand All @@ -2985,7 +2979,6 @@ fn test_cp_copy_symlink_contents_recursive() {
fn test_cp_mode_symlink() {
for from in ["file", "slink", "slink2"] {
let (at, mut ucmd) = at_and_ucmd!();
at.touch("file");
at.write("file", "f");
at.relative_symlink_file("file", "slink");
at.relative_symlink_file("slink", "slink2");
Expand All @@ -3001,7 +2994,6 @@ fn test_cp_mode_symlink() {
fn test_cp_mode_hardlink() {
for from in ["file", "slink", "slink2"] {
let (at, mut ucmd) = at_and_ucmd!();
at.touch("file");
at.write("file", "f");
at.relative_symlink_file("file", "slink");
at.relative_symlink_file("slink", "slink2");
Expand All @@ -3019,7 +3011,6 @@ fn test_cp_mode_hardlink() {
#[test]
fn test_cp_mode_hardlink_no_dereference() {
let (at, mut ucmd) = at_and_ucmd!();
at.touch("file");
at.write("file", "f");
at.relative_symlink_file("file", "slink");
at.relative_symlink_file("slink", "slink2");
Expand Down Expand Up @@ -3836,7 +3827,6 @@ fn test_acl_preserve() {
fn test_cp_debug_reflink_never_with_hole() {
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
at.touch("a");
at.write("a", "hello");
let f = std::fs::OpenOptions::new()
.write(true)
Expand Down Expand Up @@ -3926,8 +3916,7 @@ fn test_cp_debug_default_less_than_512_bytes() {
let ts = TestScenario::new(util_name!());

let at = &ts.fixtures;
at.touch("a");
at.append_bytes("a", "hello".as_bytes());
at.write_bytes("a", "hello".as_bytes());
let f = std::fs::OpenOptions::new()
.write(true)
.open(at.plus("a"))
Expand Down Expand Up @@ -3955,8 +3944,7 @@ fn test_cp_debug_default_without_hole() {
let ts = TestScenario::new(util_name!());

let at = &ts.fixtures;
at.touch("a");
at.append_bytes("a", "hello".as_bytes());
at.write_bytes("a", "hello".as_bytes());

let filler_bytes = [0_u8; 10000];

Expand Down Expand Up @@ -4001,7 +3989,6 @@ fn test_cp_debug_default_empty_file_with_hole() {
fn test_cp_debug_reflink_never_sparse_always_with_hole() {
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
at.touch("a");
at.write("a", "hello");
let f = std::fs::OpenOptions::new()
.write(true)
Expand Down Expand Up @@ -4036,7 +4023,6 @@ fn test_cp_debug_reflink_never_sparse_always_without_hole() {
let ts = TestScenario::new(util_name!());
let empty_bytes = [0_u8; 10000];
let at = &ts.fixtures;
at.touch("a");
at.write("a", "hello");
at.append_bytes("a", &empty_bytes);

Expand Down Expand Up @@ -4210,8 +4196,7 @@ fn test_cp_debug_reflink_never_less_than_512_bytes() {
let ts = TestScenario::new(util_name!());

let at = &ts.fixtures;
at.touch("a");
at.append_bytes("a", "hello".as_bytes());
at.write_bytes("a", "hello".as_bytes());
let f = std::fs::OpenOptions::new()
.write(true)
.open(at.plus("a"))
Expand Down Expand Up @@ -4289,8 +4274,7 @@ fn test_cp_debug_sparse_never_less_than_512_bytes() {
let ts = TestScenario::new(util_name!());

let at = &ts.fixtures;
at.touch("a");
at.append_bytes("a", "hello".as_bytes());
at.write_bytes("a", "hello".as_bytes());
let f = std::fs::OpenOptions::new()
.write(true)
.open(at.plus("a"))
Expand Down Expand Up @@ -4318,8 +4302,7 @@ fn test_cp_debug_sparse_never_without_hole() {
let ts = TestScenario::new(util_name!());

let at = &ts.fixtures;
at.touch("a");
at.append_bytes("a", "hello".as_bytes());
at.write_bytes("a", "hello".as_bytes());

let filler_bytes = [0_u8; 10000];

Expand Down Expand Up @@ -4451,7 +4434,6 @@ fn test_cp_debug_reflink_never_without_hole() {
let ts = TestScenario::new(util_name!());
let filler_bytes = [0_u8; 1000];
let at = &ts.fixtures;
at.touch("a");
at.write("a", "hello");
at.append_bytes("a", &filler_bytes);
let result = ts
Expand Down
Loading