From dbed808c7d534069f76e63a1a68a85f30d2be81c Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 10 Sep 2019 23:23:43 +0300 Subject: Move testscript builtins to libbutl --- tests/test/script/builtin/cp.testscript | 367 ++++---------------------------- 1 file changed, 45 insertions(+), 322 deletions(-) (limited to 'tests/test/script/builtin/cp.testscript') diff --git a/tests/test/script/builtin/cp.testscript b/tests/test/script/builtin/cp.testscript index 60497b1..802cfee 100644 --- a/tests/test/script/builtin/cp.testscript +++ b/tests/test/script/builtin/cp.testscript @@ -4,109 +4,29 @@ .include ../common.testscript -: unknown-option -: -$c <"cp: unknown option '-u'" == 1 -EOI - -: 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 + : cleanup : { - : 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 - } + touch a; + cp --no-cleanup a b; + rm b + EOI - : cleanup - : - { : existing : : Test that copy over an existing file does not register cleanup. If it @@ -114,12 +34,12 @@ EOI : 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 + touch a/b; + cp -r a b EOI - } - : non-dir + : no-cleanup : - { - $c <>/~%EOE% != 0 - %cp: unable to copy directory '.+/a' to '.+/b': .+% - EOE + $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 + cp a b c/ 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 + : no-cleanup : - { $c <>/~%EOE% != 0 - %cp: unable to copy file '.+/a' to '.+/b/a': .+% - EOE - EOI - } + touch a b; + mkdir c; + cp --no-cleanup a b c/; + rm c/a c/b + EOI } : filesystem-entries @@ -279,112 +94,20 @@ EOI : Test synopsis 4: copy filesystem entries into the specified directory. : { - : file + : cleanup : - { - $c <>/~%EOE% != 0 - %cp: unable to copy directory '.+/a' to '.+/b/a': .+% - EOE + touch c a/c; + cp --no-cleanup -R a c b/; + rm -r b/a/ b/c EOI - } -} - -: attrs -: -if ($cxx.target.class != 'windows') -{ - fs = 's/.+ (\S+\s+\S+\s+\S+)\s+cp-file/\1/p' - ds = 's/.+ (\S+\s+\S+\s+\S+)\s+cp-dir/\1/p' - - : copy - : - { - : file - : - { - $c <<"EOI" && $b - ls -l $src_base/cp-dir | sed -n -e '$fs' | \ - set t; - - cp -p $src_base/cp-dir/cp-file ./; - ls -l | sed -n -e '$fs' >"\$t" - EOI - } - - : dir - : - { - $c <<"EOI" && $b - ls -l $src_base | sed -n -e '$ds' | \ - set t; - - cp -pr $src_base/cp-dir ./; - ls -l | sed -n -e '$ds' >"\$t" - EOI - } - } - - : no-copy - : - { - : file - : - { - $c <<"EOI" && $b 2>>~%EOE% != 0 - ls -l $src_base/cp-dir | sed -n -e '$fs' | \ - set t; - - cp $src_base/cp-dir/cp-file ./; - ls -l | sed -n -e '$fs' >"\$t" - EOI - %.+ error: sed stdout doesn't match expected% - %.+ - EOE - } - - : dir - : - : Note that the `ls -l` command by default displays the filesystem entry - : modification time with the minute resolution and the build2 dist - : meta-operation (involved when we fetch from the git repository - : location) doesn't preserve the directory modification time. That's why - : we also pass --full-time and enable the test for only platforms where ls - : supports this option. - : - if ($cxx.target.class == 'linux') - { - $c <<"EOI" && $b 2>>~%EOE% != 0 - ls -l --full-time $src_base | sed -n -e '$ds' | \ - set t; - - cp -r $src_base/cp-dir ./; - ls -l --full-time | sed -n -e '$ds' >"\$t" - EOI - %.+ error: sed stdout doesn't match expected% - %.+ - EOE - } - } } -- cgit v1.1