# file : tests/test/script/builtin/cp.test # copyright : Copyright (c) 2014-2017 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file .include ../common.test : args : { : none : $c <'cp 2>"cp: missing arguments" == 1' && $b : no-source : $c <'cp -R a 2>"cp: missing source path" == 1' && $b : no-trailing-sep : $c <"cp: multiple source paths without trailing separator for destination directory" == 1 EOI : empty : { : dest : $c <"cp: invalid path ''" == 1 EOI : src1 : $c <"cp: invalid path ''" == 1 EOI : src2 : $c <"cp: invalid path ''" == 1 EOI } } : file : : Test synopsis 1: make a file copy at the specified path. : { : existing : { : to-non-existing : $c <>/~%EOE% != 0 %cp: unable to copy file '.+/a' to '.+/b': .+% EOE EOI } : non-existing : { $c <>/~%EOE% != 0 %cp: unable to copy file '.+/a' to '.+/b': .+% EOE EOI } : non-file : { $c <>/~%EOE% != 0 %cp: unable to copy file '.+/a' to '.+/b': .+% EOE EOI } : cleanup : { : existing : : Test that copy over an existing file doesn't register cleanup. If it does : then the file would be removed while leaving the embedded scope, and so : the cleanup registered by the outer touch would fail. : $c <>/~%EOE% != 0 %cp: unable to copy directory '.+/a' to '.+/b': .+% EOE EOI : to-file : $c <>/~%EOE% != 0 %cp: unable to copy directory '.+/a' to '.+/b': .+% EOE EOI : recursively : { $c <>/~%EOE% != 0 %cp: unable to copy directory '.+/a' to '.+/b': .+% EOE EOI } : non-dir : { $c <>/~%EOE% != 0 %cp: unable to copy directory '.+/a' to '.+/b': .+% EOE EOI } } : files : : Test synopsis 3: copy files into the specified directory. : { : existing : { : into-dir : { : over-non-existing : $c <>/~%EOE% != 0 %cp: unable to copy file '.+/a' to '.+/b/a': .+% EOE EOI : multiple : $c <>/~%EOE% != 0 %cp: unable to copy file '.+/a' to '.+/b/a': .+% EOE EOI } : into-non-dir : { $c <>/~%EOE% != 0 %cp: unable to copy file '.+/a' to '.+/b/a': .+% EOE EOI } } : non-existing : { $c <>/~%EOE% != 0 %cp: unable to copy file '.+/a' to '.+/b/a': .+% EOE EOI } : non-file : { $c <>/~%EOE% != 0 %cp: unable to copy file '.+/a' to '.+/b/a': .+% EOE EOI } } : filesystem-entries : : Test synopsis 4: copy filesystem entries into the specified directory. : { : file : { $c <>/~%EOE% != 0 %cp: unable to copy directory '.+/a' to '.+/b/a': .+% EOE EOI } }