From: Joe Souza jsouza@yahoo.com
--- programs/cmd/tests/test_builtins.cmd | 79 ++++++++++++++++++------ programs/cmd/tests/test_builtins.cmd.exp | 42 +++++++++++++ 2 files changed, 102 insertions(+), 19 deletions(-)
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index 58d78194380..8ae733681eb 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -3416,6 +3416,30 @@ shift if not "%1"=="" goto :CheckNotExist goto :eof
+:CheckOutputExist +find /i "%1" test1.txt >nul 2>&1 +if errorlevel 0 ( + echo Passed: Found expected %1 in COPY output +) else ( + echo Failed: Did not find expected %1 in COPY output +) +shift +if not "%1"=="" goto :CheckOutputExist +del /q test1.txt >nul 2>&1 +goto :eof + +:CheckOutputNotExist +find /i "%1" test1.txt >nul 2>&1 +if errorlevel 1 ( + echo Passed: Did not find %1 in COPY output +) else ( + echo Failed: Unexpectedly found %1 in COPY output +) +shift +if not "%1"=="" goto :CheckOutputNotExist +del /q test1.txt >nul 2>&1 +goto :eof + rem Note: No way to check file size on NT4 so skip the test :CheckFileSize if not exist "%1" ( @@ -3444,28 +3468,33 @@ rem ----------------------- rem Simple single file copy rem ----------------------- rem Simple single file copy, normally used syntax -copy file1 dummy.file >nul 2>&1 +copy file1 dummy.file >test1.txt 2>&1 if errorlevel 1 echo Incorrect errorlevel +call :CheckOutputNotExist file1 call :CheckExist dummy.file
rem Simple single file copy, destination supplied as two forms of directory -copy file1 dir1 >nul 2>&1 +copy file1 dir1 >test1.txt 2>&1 if errorlevel 1 echo Incorrect errorlevel +call :CheckOutputNotExist file1 call :CheckExist dir1\file1
-copy file1 dir1\ >nul 2>&1 +copy file1 dir1\ >test1.txt 2>&1 if errorlevel 1 echo Incorrect errorlevel +call :CheckOutputNotExist file1 call :CheckExist dir1\file1
rem Simple single file copy, destination supplied as fully qualified destination -copy file1 dir1\file99 >nul 2>&1 +copy file1 dir1\file99 >test1.txt 2>&1 if errorlevel 1 echo Incorrect errorlevel +call :CheckOutputNotExist file1 call :CheckExist dir1\file99
rem Simple single file copy, destination not supplied cd dir1 -copy ..\file1 >nul 2>&1 +copy ..\file1 >test1.txt 2>&1 if errorlevel 1 echo Incorrect errorlevel +call :CheckOutputNotExist file1 call :CheckExist file1 cd ..
@@ -3477,19 +3506,22 @@ call :CheckNotExist dir2 dir2\file1 rem ----------------------- rem Wildcarded copy rem ----------------------- -rem Simple single file copy, destination supplied as two forms of directory -copy file? dir1 >nul 2>&1 +rem Simple wildcarded file copy, destination supplied as two forms of directory +copy file? dir1 >test1.txt 2>&1 if errorlevel 1 echo Incorrect errorlevel +call :CheckOutputExist file1 file2 file3 call :CheckExist dir1\file1 dir1\file2 dir1\file3
-copy file* dir1\ >nul 2>&1 +copy file* dir1\ >test1.txt 2>&1 if errorlevel 1 echo Incorrect errorlevel +call :CheckOutputExist file1 file2 file3 call :CheckExist dir1\file1 dir1\file2 dir1\file3
-rem Simple single file copy, destination not supplied +rem Simple wildcarded file copy, destination not supplied cd dir1 -copy ..\file*.* >nul 2>&1 +copy ..\file*.* >test1.txt 2>&1 if errorlevel 1 echo Incorrect errorlevel +call :CheckOutputExist file1 file2 file3 call :CheckExist file1 file2 file3 cd ..
@@ -3502,51 +3534,60 @@ rem ------------------------------------------------ rem Confirm overwrite works (cannot test prompting!) rem ------------------------------------------------ copy file1 testfile >nul 2>&1 -copy /y file2 testfile >nul 2>&1 +copy /y file2 testfile >test1.txt 2>&1 +call :CheckOutputNotExist file2 call :CheckExist testfile
rem ------------------------------------------------ rem Test concatenation rem ------------------------------------------------ rem simple case, no wildcards -copy file1+file2 testfile >nul 2>&1 +copy file1+file2 testfile >test1.txt 2>&1 if errorlevel 1 echo Incorrect errorlevel +call :CheckOutputExist file1 file2 call :CheckExist testfile
rem simple case, wildcards, no concatenation -copy file* testfile >nul 2>&1 +copy file* testfile >test1.txt 2>&1 if errorlevel 1 echo Incorrect errorlevel +call :CheckOutputExist file1 file2 file3 call :CheckExist testfile
rem simple case, wildcards, and concatenation echo ddddd > fred -copy file*+fred testfile >nul 2>&1 +copy file*+fred testfile >test1.txt 2>&1 if errorlevel 1 echo Incorrect errorlevel +call :CheckOutputExist file1 file2 file3 fred call :CheckExist testfile
rem simple case, wildcards, and concatenation -copy fred+file* testfile >nul 2>&1 +copy fred+file* testfile >test1.txt 2>&1 if errorlevel 1 echo Incorrect errorlevel +call :CheckOutputExist fred file1 file2 file3 call :CheckExist testfile
rem Calculate destination name -copy fred+file* dir1 >nul 2>&1 +copy fred+file* dir1 >test1.txt 2>&1 if errorlevel 1 echo Incorrect errorlevel +call :CheckOutputExist fred file1 file2 file3 call :CheckExist dir1\fred
rem Calculate destination name -copy fred+file* dir1\ >nul 2>&1 +copy fred+file* dir1\ >test1.txt 2>&1 if errorlevel 1 echo Incorrect errorlevel +call :CheckOutputExist fred file1 file2 file3 call :CheckExist dir1\fred
rem Calculate destination name (none supplied) cd dir1 -copy ..\fred+..\file* >nul 2>&1 +copy ..\fred+..\file* >test1.txt 2>&1 if errorlevel 1 echo Incorrect errorlevel +call :CheckOutputExist fred file1 file2 file3 call :CheckExist fred
-copy ..\fr*+..\file1 >nul 2>&1 +copy ..\fr*+..\file1 >test1.txt 2>&1 if errorlevel 1 echo Incorrect errorlevel +call :CheckOutputExist fred file1 call :CheckExist fred cd ..
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index ff6f944cffb..95feb67602b 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -1936,19 +1936,33 @@ file correctly deleted --- a batch file can alter itself bar ---------- Testing copy +Passed: Did not find file1 in COPY output Passed: Found expected dummy.file +Passed: Did not find file1 in COPY output Passed: Found expected dir1\file1 +Passed: Did not find file1 in COPY output Passed: Found expected dir1\file1 +Passed: Did not find file1 in COPY output Passed: Found expected dir1\file99 +Passed: Did not find file1 in COPY output Passed: Found expected file1 Passed: Did not find dir2 Passed: Did not find dir2\file1 +Passed: Found expected file1 in COPY output +Passed: Found expected file2 in COPY output +Passed: Found expected file3 in COPY output Passed: Found expected dir1\file1 Passed: Found expected dir1\file2 Passed: Found expected dir1\file3 +Passed: Found expected file1 in COPY output +Passed: Found expected file2 in COPY output +Passed: Found expected file3 in COPY output Passed: Found expected dir1\file1 Passed: Found expected dir1\file2 Passed: Found expected dir1\file3 +Passed: Found expected file1 in COPY output +Passed: Found expected file2 in COPY output +Passed: Found expected file3 in COPY output Passed: Found expected file1 Passed: Found expected file2 Passed: Found expected file3 @@ -1956,14 +1970,42 @@ Passed: Did not find dir2 Passed: Did not find dir2\file1 Passed: Did not find dir2\file2 Passed: Did not find dir2\file3 +Passed: Did not find file2 in COPY output Passed: Found expected testfile +Passed: Found expected file1 in COPY output +Passed: Found expected file2 in COPY output Passed: Found expected testfile +Passed: Found expected file1 in COPY output +Passed: Found expected file2 in COPY output +Passed: Found expected file3 in COPY output Passed: Found expected testfile +Passed: Found expected file1 in COPY output +Passed: Found expected file2 in COPY output +Passed: Found expected file3 in COPY output +Passed: Found expected fred in COPY output Passed: Found expected testfile +Passed: Found expected fred in COPY output +Passed: Found expected file1 in COPY output +Passed: Found expected file2 in COPY output +Passed: Found expected file3 in COPY output Passed: Found expected testfile +Passed: Found expected fred in COPY output +Passed: Found expected file1 in COPY output +Passed: Found expected file2 in COPY output +Passed: Found expected file3 in COPY output Passed: Found expected dir1\fred +Passed: Found expected fred in COPY output +Passed: Found expected file1 in COPY output +Passed: Found expected file2 in COPY output +Passed: Found expected file3 in COPY output Passed: Found expected dir1\fred +Passed: Found expected fred in COPY output +Passed: Found expected file1 in COPY output +Passed: Found expected file2 in COPY output +Passed: Found expected file3 in COPY output Passed: Found expected fred +Passed: Found expected fred in COPY output +Passed: Found expected file1 in COPY output Passed: Found expected fred Passed: file size check on file1 [5]@or_broken@Skipping file size check on NT4 Passed: file size check on file2 [8]@or_broken@Skipping file size check on NT4