From 73bce5b488dee27515e1469ca5d985dd52a590c3 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 8 Sep 2025 14:10:32 -0500 Subject: [PATCH] Convert testing->testcmd. --- tests/cp.test | 97 +++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 49 deletions(-) diff --git a/tests/cp.test b/tests/cp.test index 1ffd3cae..d456f36b 100755 --- a/tests/cp.test +++ b/tests/cp.test @@ -10,49 +10,47 @@ dd if=/dev/urandom of=random bs=64 count=1 2> /dev/null #testing "name" "command" "result" "infile" "stdin" -testing "not enough arguments [fail]" "cp one 2>/dev/null || echo yes" \ +testcmd "not enough arguments [fail]" "one 2>/dev/null || echo yes" \ "yes\n" "" "" -testing "-missing source [fail]" "cp missing two 2>/dev/null || echo yes" \ +testcmd "-missing source [fail]" "missing two 2>/dev/null || echo yes" \ "yes\n" "" "" -testing "file->file" "cp random two && cmp random two && echo yes" \ +testcmd "file->file" "random two && cmp random two && echo yes" \ "yes\n" "" "" rm two mkdir two -testing "file->dir" "cp random two && cmp random two/random && echo yes" \ +testcmd "file->dir" "random two && cmp random two/random && echo yes" \ "yes\n" "" "" rm two/random -testing "file->dir/file" \ - "cp random two/random && cmp random two/random && echo yes" \ - "yes\n" "" "" -testing "-r dir->missing" \ - "cp -r two three && cmp random three/random && echo yes" \ - "yes\n" "" "" +testcmd "file->dir/file" \ + "random two/random && cmp random two/random && echo yes" "yes\n" "" "" +testcmd "-r dir->missing" \ + "-r two three && cmp random three/random && echo yes" "yes\n" "" "" touch walrus -testing "-r dir->file [fail]" \ - "cp -r two walrus 2>/dev/null || echo yes" "yes\n" "" "" +testcmd "-r dir->file [fail]" \ + "-r two walrus 2>/dev/null || echo yes" "yes\n" "" "" touch two/three -testing "-r dir hits file." \ - "cp -r three two 2>/dev/null || echo yes" "yes\n" "" "" +testcmd "-r dir hits file." \ + "-r three two 2>/dev/null || echo yes" "yes\n" "" "" rm -rf two three walrus touch two chmod 000 two skipnot [ $(id -u) -ne 0 ] # Root doesn't count. -testing "file->inaccessible [fail]" \ - "cp random two 2>/dev/null || echo yes" "yes\n" "" "" +testcmd "file->inaccessible [fail]" \ + "random two 2>/dev/null || echo yes" "yes\n" "" "" rm -f two touch two chmod 000 two skipnot [ $(id -u) -ne 0 ] # Root doesn't count. -testing "-f file->inaccessible" \ - "cp -f random two && cmp random two && echo yes" "yes\n" "" "" +testcmd "-f file->inaccessible" \ + "-f random two && cmp random two && echo yes" "yes\n" "" "" mkdir sub chmod 000 sub skipnot [ $(id -u) -ne 0 ] # Root doesn't count. -testing "file->inaccessible_dir [fail]" \ - "cp random sub 2>/dev/null || echo yes" "yes\n" "" "" +testcmd "file->inaccessible_dir [fail]" \ + "random sub 2>/dev/null || echo yes" "yes\n" "" "" rm two rmdir sub @@ -71,73 +69,74 @@ rm -f file #rm -rf dir file touch one two -testing "file1 file2 missing [fail]" \ - "cp one two missing 2>/dev/null || echo yes" "yes\n" "" "" +testcmd "file1 file2 missing [fail]" \ + "one two missing 2>/dev/null || echo yes" "yes\n" "" "" mkdir dir -testing "dir file missing [fail]" \ - "cp dir two missing 2>/dev/null || echo yes" "yes\n" "" "" -testing "-rf dir file missing [fail]" \ - "cp dir two missing 2>/dev/null || echo yes" "yes\n" "" "" -testing "file1 file2 file [fail]" \ - "cp random one two 2>/dev/null || echo yes" "yes\n" "" "" -testing "file1 file2 dir" \ - "cp random one dir && cmp random dir/random && cmp one dir/one && echo yes" \ +testcmd "dir file missing [fail]" \ + "dir two missing 2>/dev/null || echo yes" "yes\n" "" "" +testcmd "-rf dir file missing [fail]" \ + "dir two missing 2>/dev/null || echo yes" "yes\n" "" "" +testcmd "file1 file2 file [fail]" \ + "random one two 2>/dev/null || echo yes" "yes\n" "" "" +testcmd "file1 file2 dir" \ + "random one dir && cmp random dir/random && cmp one dir/one && echo yes" \ "yes\n" "" "" rm one two random rm -rf dir mkdir -p one/two/three/four touch one/two/three/five one/{six,seven,eight} -testing "-r /abspath dest" \ - "cp -r \"$(readlink -f one)\" dir && diff -r one dir && echo yes" \ +testcmd "-r /abspath dest" \ + "-r \"$(readlink -f one)\" dir && diff -r one dir && echo yes" \ "yes\n" "" "" -testing "-r dir again" "cp -r one/. dir && diff -r one dir && echo yes" \ +testcmd "-r dir again" "-r one/. dir && diff -r one dir && echo yes" \ "yes\n" "" "" mkdir dir2 -testing "-r dir1/* dir2" \ - "cp -r one/* dir2 && diff -r one dir2 && echo yes" "yes\n" "" "" +testcmd "-r dir1/* dir2" \ + "-r one/* dir2 && diff -r one dir2 && echo yes" "yes\n" "" "" rm -rf one dir dir2 mkdir one; touch one/two; cp one/two one/three cp -pr one/ one_ # Succeeds twice in a row -testing "-pr dir/." "cp -pr one/. one_ && echo yes" "yes\n" "" "" +testcmd "-pr dir/." "-pr one/. one_ && echo yes" "yes\n" "" "" rm -rf one one_ mkdir one; touch one/two; ln -s two one/three cp -pr one/ one_ # First time ok, second mustn't fail with "File exists" -testing "-pr dir/. symlink child" "cp -pr one/. one_ && echo yes" "yes\n" "" "" +testcmd "-pr dir/. symlink child" "-pr one/. one_ && echo yes" "yes\n" "" "" rm -rf one one_ touch walrus chmod 644 walrus ln -s walrus woot -testing "symlink dest permissions" "cp woot carpenter && stat -c %A carpenter" \ +testcmd "symlink dest permissions" "woot carpenter && stat -c %A carpenter" \ "-rw-r--r--\n" "" "" -testing "duplicated --preserve options" \ - "cp --preserve=mode,mode walrus walrus2 2>&1 || echo bad" "" "" "" +testcmd "duplicated --preserve options" \ + "--preserve=mode,mode walrus walrus2 2>&1 || echo bad" "" "" "" rm -rf walrus woot carpenter mkdir dir echo a > file echo b > b -testing "-T file" "cp -T b file && cat file" "b\n" "" "" -testing "-T dir" "cp -T b dir 2>/dev/null || echo expected" "expected\n" "" "" +testcmd "-T file" "-T b file && cat file" "b\n" "" "" +testcmd "-T dir" "-T b dir 2>/dev/null || echo expected" "expected\n" "" "" rm b file mkdir -p b/c/d/ a/ echo a > b/c/d/file -testing "--parents b/c/d/file a/" "cp --parents b/c/d/file a/ && cat a/b/c/d/file" "a\n" "" "" +testcmd "--parents b/c/d/file a/" "--parents b/c/d/file a/ && cat a/b/c/d/file"\ + "a\n" "" "" rm -rf a/ b/ echo a > file -testing "-P file" "cp -P file fdst && stat -c %F fdst" "regular file\n" "" "" +testcmd "-P file" "-P file fdst && stat -c %F fdst" "regular file\n" "" "" ln -s file lnk -testing "-P symlink" "cp -P lnk ldst && stat -c %F ldst" "symbolic link\n" "" "" -testing "follow symlink" "cp lnk ldst2 && stat -c %F ldst2" "regular file\n" "" "" +testcmd "-P symlink" "-P lnk ldst && stat -c %F ldst" "symbolic link\n" "" "" +testcmd "follow symlink" "lnk ldst2 && stat -c %F ldst2" "regular file\n" "" "" rm file fdst lnk ldst ldst2 mkdir sub -testing "-t one arg" 'cp -t sub/ input && cat sub/input' 'yes\n' 'yes\n' '' -toyonly testing "-Dt" 'cp -Dt sub2 input && cat sub2/input' 'and\n' 'and\n' '' +testcmd "-t one arg" '-t sub/ input && cat sub/input' 'yes\n' 'yes\n' '' +toyonly testcmd "-Dt" '-Dt sub2 input && cat sub2/input' 'and\n' 'and\n' '' rm -rf sub sub2 testing '-u1' 'echo one>one; sleep .1; echo two>two; cp -u one two; cat two' \ @@ -149,7 +148,7 @@ mkdir a b echo potato > a/one echo potato > a/two touch b/one b/two -testing '-i' 'cp -ri a/. b/. 2>/dev/null; cmp -s a/one b/one || cmp -s a/one b/two && echo yes' \ +testcmd '-i' '-ri a/. b/. 2>/dev/null; cmp -s a/one b/one || cmp -s a/one b/two && echo yes' \ 'yes\n' '' 'n\ny\n' rm -rf one two a b -- 2.39.5