]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blobdiff - src/allmydata/test/test_cli_cp.py
cp: error on target-filename collisions, rather than overwrite
[tahoe-lafs/tahoe-lafs.git] / src / allmydata / test / test_cli_cp.py
index 80be26819e96eddcfaedb0aaf2f369ecbdebc8ea..3c8bc80a931232ec3205554cf172cb7bd335d3a0 100644 (file)
@@ -658,7 +658,9 @@ starting copy, 2 files, 1 directories
 
 # these test cases come from ticket #2329 comment 40
 # trailing slash on target *directory* should not matter, test both
-# trailing slash on files should cause error
+# trailing slash on target files should cause error
+# trailing slash on source directory should not matter, test a few
+# trailing slash on source files should cause error
 
 COPYOUT_TESTCASES = """
 cp    $FILECAP          to/existing-file : to/existing-file
@@ -680,16 +682,22 @@ cp    $FILECAP $DIRCAP  to/existing-file/ : E4-NEED-R
 cp -r $FILECAP $DIRCAP  to/existing-file/ : E7-BADSLASH
 
 # single source to a (present) target directory
-cp    $FILECAP       to : E2-DESTNAME
-cp -r $FILECAP       to : E2-DESTNAME
-cp    $DIRCAP/file   to : to/file
-cp -r $DIRCAP/file   to : to/file
-cp    $PARENTCAP/dir to : E4-NEED-R
-cp -r $PARENTCAP/dir to : to/dir/file
-cp    $DIRCAP        to : E4-NEED-R
-cp -r $DIRCAP        to : to/file
-cp    $DIRALIAS      to : E4-NEED-R
-cp -r $DIRALIAS      to : to/file
+cp    $FILECAP        to : E2-DESTNAME
+cp -r $FILECAP        to : E2-DESTNAME
+cp    $DIRCAP/file    to : to/file
+cp -r $DIRCAP/file    to : to/file
+# these two are errors
+cp    $DIRCAP/file/   to : E8-BADSLASH
+cp -r $DIRCAP/file/   to : E8-BADSLASH
+cp    $PARENTCAP/dir  to : E4-NEED-R
+cp -r $PARENTCAP/dir  to : to/dir/file
+# but these two should ignore the trailing source slash
+cp    $PARENTCAP/dir/ to : E4-NEED-R
+cp -r $PARENTCAP/dir/ to : to/dir/file
+cp    $DIRCAP         to : E4-NEED-R
+cp -r $DIRCAP         to : to/file
+cp    $DIRALIAS       to : E4-NEED-R
+cp -r $DIRALIAS       to : to/file
 
 cp    $FILECAP       to/ : E2-DESTNAME
 cp -r $FILECAP       to/ : E2-DESTNAME
@@ -779,11 +787,11 @@ cp -r $PARENTCAP/dir3/file3 $DIRCAP $PARENTCAP/dir2 $FILECAP to/missing/ : E2-DE
 cp -r $PARENTCAP/dir4 to  : to/dir4/emptydir/
 cp -r $PARENTCAP/dir4 to/ : to/dir4/emptydir/
 
-# name collisions: ensure files are copied in order
-cp -r $PARENTCAP/dir6/dir $PARENTCAP/dir5/dir to : to/dir/collide=5
-cp -r $PARENTCAP/dir5/dir $PARENTCAP/dir6/dir to : to/dir/collide=6
-cp -r $DIRCAP6 $DIRCAP5 to : to/dir/collide=5
-cp -r $DIRCAP5 $DIRCAP6 to : to/dir/collide=6
+# name collisions should cause errors, not overwrites
+cp -r $PARENTCAP/dir6/dir $PARENTCAP/dir5/dir to : E9-COLLIDING-TARGETS
+cp -r $PARENTCAP/dir5/dir $PARENTCAP/dir6/dir to : E9-COLLIDING-TARGETS
+cp -r $DIRCAP6 $DIRCAP5 to : E9-COLLIDING-TARGETS
+cp -r $DIRCAP5 $DIRCAP6 to : E9-COLLIDING-TARGETS
 
 """
 
@@ -941,6 +949,11 @@ class CopyOut(GridTestMixin, CLITestMixin, unittest.TestCase):
                     return set(["E6-MANYONE"])
                 if err == "target is not a directory, but ends with a slash":
                     return set(["E7-BADSLASH"])
+                if err == "cannot copy multiple files with the same name into the same target directory":
+                    return set(["E9-COLLIDING-TARGETS"])
+                if (err.startswith("source ") and
+                    "is not a directory, but ends with a slash" in err):
+                    return set(["E8-BADSLASH"])
             self.fail("unrecognized error ('%s') %s" % (case, res))
         d.addCallback(_check)
         return d