Skip to content
Snippets Groups Projects
test_builtins.cmd.exp 14.8 KiB
Newer Older
@pwd@>echo Tests for cmd's builtin commands@space@
Tests for cmd's builtin commands
@pwd@>echo ------------ Testing 'echo' [ON] ------------@space@
------------ Testing 'echo' [ON] ------------

@pwd@>echo word@space@
word

@pwd@>echo 'singlequotedword'@space@
'singlequotedword'

@pwd@>echo "doublequotedword"@space@
"doublequotedword"
at-echoed-word

@pwd@>echo "/?"@space@
"/?"

@pwd@>echo word@space@@space@
word@space@

@pwd@>echo word@space@@space@@space@
word@space@@space@
@pwd@>echo word@space@
word

@pwd@>echo@tab@word@space@

@pwd@>echo@tab@word@space@@tab@@space@
word@space@@tab@

@pwd@>echo@tab@word@tab@@space@@space@
word@tab@@space@
@pwd@>echo word@space@
word

@pwd@>echo@space@@tab@word@space@
@tab@word

@pwd@>echo@space@@space@@tab@word@space@
@space@@tab@word

@pwd@>echo@tab@@tab@word@space@
@tab@word

@pwd@>echo @tab@ on @space@@space@
------------ Testing 'echo' [OFF] ------------
Jacek Caban's avatar
Jacek Caban committed
word
'singlequotedword'
"doublequotedword"
at-echoed-word
"/?"

.
word
word@space@@tab@
word@tab@@space@
word
@tab@word
@space@@tab@word
@tab@word
------------ Testing mixed echo modes ------------
@echo on
if 1==1 echo foo
if 1==1 @echo bar
@echo off
if 1==1 echo foo2
if 1==1 @echo bar2

@todo_wine@@pwd@>if 1 == 1 echo foo@space@
foo

@todo_wine@@pwd@>if 1 == 1@space@
bar
foo2
bar2
------------ Testing parameterization ------------
'a', 'b', 'c'
'"a b c"', '', ''
'"a b"\c', '', ''
'a', '~`+', '.{}!+b'
'a', 'b', ''
'"a;b"', '', ''
'a[b]{c}(d)e', '', ''
'a', '', ''
second line
'a', 'b', 'c'
'a', 'b', 'c'
'a', 'b', ''
------------ Testing rem ------------

@pwd@>rem Hello@space@

@pwd@>rem  Hello@space@

@pwd@>rem   Hello || foo@space@

@pwd@>rem echo lol@space@

@pwd@>rem echo foo & echo bar@space@

@pwd@>rem @tab@  Hello@space@

@pwd@>rem@tab@  Hello@space@

@pwd@>rem@tab@echo foo & echo bar@space@
------------ Testing redirection operators ------------
foo@tab@
foo@space@
foo@tab@
foo7@space@@or_broken@foo@tab@
foo9@space@@or_broken@foo@tab@
foo1
foo11
foo12
foo
foo@space@
foob@space@
foob@space@
fooc@space@
foob@space@
fooc@space@
food1
foob@space@
fooc@space@
food1
food2
food21
@todo_wine@foo7@space@@space@@or_broken@not supported@space@
@todo_wine@foo@or_broken@not supported
file does not exist, ok
------------ Testing circumflex escape character ------------
hello, world
hello, world
hell^o, world
hell^o, world
foo | echo bar
foo & echo bar
bak &
foo > foo
<
ffoof
FOO=bar | baz
0
FOO=bar ^| baz
bar | baz
0
------------ Testing 'set' ------------
FOOBAR not defined
FOOBAR =  baz
FOOBAR= bar
FOOBAR =  baz2
FOOBAR not defined
1
bar
foobar
FOO not defined
BAZ=bazbaz
bazbaz
set "FOO=bar" should not include the quotes in the variable value
bar
'foo@space@'
'foo@tab@'
------------ Testing variable expansion ------------
~dp0 should be directory containing batch file
@pwd@\
@pwd@\
0ERRORLEVEL
------------ Testing variable substrings ------------
q
qwe
er
@todo_wine@'ty'@or_broken@''
't'@or_broken@''
ert@or_broken@qwerty
e@or_broken@qwerty
''@or_broken@'qwerty'
r@or_broken@qwerty
------------ Testing variable substitution ------------
'A B'@or_broken@''
'C'@or_broken@''
@pwd@\C D@or_broken@%~ff
@pwd@\E@or_broken@%~ff
@drive@
@drive@
@path@@or_broken@%~pd
@path@@or_broken@%~pd
L M
N
'.OOL'
'.TABC'
''
@todo_wine@'@drive@@shortpath@R S'@or_broken@''
@todo_wine@'@drive@@shortpath@T'@or_broken@''
@todo_wine@'@drive@@shortpath@ABCDEFGHIJK.LMNOP'@or_broken@''
@todo_wine@''@or_broken@'%~ai'
@todo_wine@''@or_broken@'%~ai'
@todo_wine@'--a------'@or_broken@'%~ai'
@todo_wine@''@or_broken@'%~ti'
@todo_wine@''@or_broken@'%~ti'
@todo_wine@''@or_broken@'%~zi'
@todo_wine@''@or_broken@'%~zi'
@drive@@path@
@drive@@path@
@drive@
@drive@
@drive@
@drive@
''
'.eh'
'A B'@or_broken@''
@pwd@\E
@drive@
@drive@
@path@
@path@
'.TABC'
''
@todo_wine@'@drive@@shortpath@R S'@or_broken@''
@todo_wine@'@drive@@shortpath@T'@or_broken@''
@todo_wine@'@drive@@shortpath@ABCDEFGHIJK.LMNOP'@or_broken@''
@drive@@path@
@drive@@path@
@drive@
@drive@
@drive@
@drive@
''
'.eh'@or_broken@''
------------ Testing variable delayed expansion ------------
foo
@todo_wine@foo@or_broken@!FOO!
foo
@todo_wine@bar@or_broken@foo
0
0@or_broken@1
foo
!FOO!
foo
@todo_wine@foo@or_broken@!FOO!
foo
!FOO!
------------ Testing conditional execution ------------
@todo_wine@foo3 not created
bar4@space@
foo4
--- on failure conditional or
foo5
foo6@space@
@todo_wine@------------ Testing cd ------------
singleFile
Current dir: @pwd@\foobar@or_broken@Current dir:@space@
@pwd@\foobar
@pwd@
@pwd@\foobar
@pwd@
@pwd@\foobar
@pwd@
@pwd@\foobar\bar bak
@pwd@\foobar\bar bak
@pwd@\foobar\bar bak
@pwd@\foobar\bar bak
@pwd@\foobar\bar bak
Frédéric Delanoy's avatar
Frédéric Delanoy committed
@pwd@\foobar
------------ Testing type ------------

@pwd@>type foobaz@space@
bar

------------ Testing NUL ------------
bar
bar
bar
NUL
@todo_wine@foo created
------------ Testing if/else ------------
Dan Kegel's avatar
Dan Kegel committed
if/else should work with blocks
if seems to work
else seems to work
if seems not to detect /c as parameter
Testing case sensitivity with and without /i option
if seems to default to case sensitivity
if /i seems to work
if /I seems to work
Testing string comparisons
equal
equal
Testing tabs handling
doom
doom
doom
lol
quake
quake
quake
------------ Testing for ------------
@todo_wine@X Y
@todo_wine@A C
@todo_wine@A D
@todo_wine@B C
@todo_wine@B D
@todo_wine@A C
@todo_wine@A D
@todo_wine@B C
@todo_wine@B D
baz@space@
foo@space@
bar@space@
PASSED
xxx - Should be xxx
Expected second line
--- for /R
Plain directory enumeration
Plain directory enumeration from provided root
File enumeration
File enumeration from provided root
Mixed enumeration
Mixed enumeration from provided root
With duplicates enumeration
Strip missing wildcards, keep unwildcarded names
for /R passed
0
@todo_wine@3
@todo_wine@-1
@todo_wine@3
@todo_wine@6
@todo_wine@10
@todo_wine@4
@todo_wine@4
@todo_wine@-4
0
@todo_wine@2
@todo_wine@2
@todo_wine@-2
@todo_wine@1
@todo_wine@4
0@or_broken@1073741824
0@or_broken@-1073741824
@todo_wine@-4
@todo_wine@9
@todo_wine@2
0
@todo_wine@-1
@todo_wine@-3
0
@todo_wine@1
@todo_wine@1
@todo_wine@4
@todo_wine@1
@todo_wine@5
@todo_wine@5
@todo_wine@7
@todo_wine@5
@todo_wine@5
@todo_wine@5
@todo_wine@4
@todo_wine@6
@todo_wine@1
@todo_wine@4
@todo_wine@10
@todo_wine@18@or_broken@10
@todo_wine@2@or_broken@0
@todo_wine@2@or_broken@0
0@or_broken@4
@todo_wine@4
@todo_wine@3@or_broken@4
@todo_wine@3@or_broken@4
@todo_wine@18
@todo_wine@18
@todo_wine@15
@todo_wine@3
@todo_wine@3@or_broken@foo not defined
@todo_wine@3@or_broken@0
@todo_wine@3@or_broken@0
@todo_wine@3@or_broken@0
@todo_wine@9@or_broken@0
0
@todo_wine@4@or_broken@0
@todo_wine@-7@or_broken@0
@todo_wine@-1@or_broken@0
@todo_wine@5@or_broken@0
@todo_wine@4@or_broken@0
@todo_wine@1@or_broken@0
0
@todo_wine@5@or_broken@0

@todo_wine@a
@todo_wine@a
@todo_wine@a
@todo_wine@a
------ fileset argument
--------- basic blank handling
@todo_wine@ad
@todo_wine@z@y
@todo_wine@no output
@todo_wine@no output
@todo_wine@a
@todo_wine@a@space@
@todo_wine@a d
@todo_wine@a
@todo_wine@C r
@todo_wine@c
@todo_wine@no output
@todo_wine@no output
------------ Testing del /a ------------
not-r.test not found after delete, good
r.test found before delete, good
r.test not found after delete, good
------------ Testing del /q ------------
del /q * succeeded on file1
del /q * succeeded on file2.dat
------------ Testing del /s ------------
------------ Testing rename ------------
foo renamed to bar
bar renamed to foo
read-only file renamed
dir renamed
read-only dir renamed
rename impossible in other directory
original file still present
------------ Testing move ------------
file move succeeded
@todo_wine@file move with overwrite succeeded@or_broken@file overwrite impossible!
@todo_wine@bar@or_broken@baz
read-only files are moveable
file moved in subdirectory
@todo_wine@moving a file to itself is a no-op@or_broken@moving a file to itself should be a no-op!
@todo_wine@ErrorLevel: 0@or_broken@ErrorLevel: 1
simple directory move succeeded
moving a directory to itself gives error; errlevel 1
------------ Testing mkdir ------------
--- creating an already existing directory/file must fail
mkdir ? gives errorlevel 1
mkdir ?\foo gives errorlevel 1
mkdir foo\? gives errorlevel 1
mkdir foo\bar\? gives errorlevel 1
bar created
foobar created
bar\baz created
bazbaz created
zabzab created
------------ Testing rmdir ------------
0
dir removed
0
dir removed
0
0
file not removed
0
non-empty dir not removed
0
non-empty dir not removed
recursive rmdir succeeded
recursive rmdir succeeded
foo removed
bar removed
foobar removed
bar\baz removed
------------ Testing pushd/popd ------------
@pwd@\foobar
@pwd@
@pwd@\foobar\baz
@pwd@\foobar
@pwd@\foobar
@pwd@
@pwd@\foobar
@pwd@
------------ Testing attrib ------------
A            @pwd@\foobar\foo@or_broken@A          @pwd@\foobar\foo@or_broken@A       I    @pwd@\foobar\foo
A    R       @pwd@\foobar\foo@or_broken@A    R     @pwd@\foobar\foo@or_broken@A    R  I    @pwd@\foobar\foo
foo
foo original contents
Read-only file not deleted
Read-only file forcibly deleted
@todo_wine@A            @pwd@\foobar\baz\level2@or_broken@A          @pwd@\foobar\baz\level2@or_broken@A       I    @pwd@\foobar\baz\level2
@todo_wine@A    R       @pwd@\foobar\level1@or_broken@A    R     @pwd@\foobar\level1@or_broken@A    R  I    @pwd@\foobar\level1
@todo_wine@A    R       @pwd@\foobar\baz\level2@or_broken@A    R     @pwd@\foobar\baz\level2@or_broken@A    R  I    @pwd@\foobar\baz\level2
A            @pwd@\foobar\bar@or_broken@A          @pwd@\foobar\bar@or_broken@A       I    @pwd@\foobar\bar
             @pwd@\foobar@or_broken@           @pwd@\foobar@or_broken@        I    @pwd@\foobar
@todo_wine@     R       @pwd@\foobar\baz@or_broken@     R     @pwd@\foobar\baz@or_broken@           @pwd@\foobar\baz@or_broken@     R  I    @pwd@\foobar\baz
@todo_wine@A            @pwd@\foobar\baz\toto@or_broken@A          @pwd@\foobar\baz\toto@or_broken@A       I    @pwd@\foobar\baz\toto
toto
lulu
file created in read-only dir
------------ Testing assoc ------------
.foo=bar
------------ Testing ftype ------------
footype=foo_opencmd
.foo=footype
footype=foo_opencmd
+++
footype=foo_opencmd
@todo_wine@original value@or_broken@buggyXP@or_broken@!FOO!
------------ Testing CALL ------------
foo@space@@space@
foo bar@space@
foo ""@space@
"" bar@space@
foo ''@space@
'' bar@space@
bar :testRoutine
foo@space@
foo bar
@todo_wine@0
@todo_wine@foo created
@todo_wine@Should expand foobaz
@todo_wine@batfile
@todo_wine@robinfile
@todo_wine@1
@todo_wine@1
non-builtin dir
------------ Testing SHIFT ------------
'p1' 'p2' 'p3' 'p4' 'p5'
'p2' 'p3' 'p4' 'p5' ''
'p3' 'p4' 'p5' '' ''
'p3' 'p5' '' '' ''
'p3' 'p5' '' '' ''
'p5' '' '' '' ''
------------ Testing cmd invocation ------------
file correctly deleted
------------ Testing setlocal/endlocal ------------
@todo_wine@ErrLev:@space@
ErrLev: 0
ErrLev: 0
@todo_wine@ErrLev:@space@@or_broken@ErrLev: 0
ErrLev: 0
@pwd@\foobar\foobar2
@pwd@\foobar\foobar2
globalval
@pwd@\foobar
--- setlocal within same batch program
Var1 ok 1
Var2 ok 2
Var3 ok 3
Directory is ok 1
Var1 ok 1
Var2 ok 2
Var3 ok 3
Directory is ok 2
Var1 ok 1
Var2 ok 2
Var3 ok 3
Directory is ok 3
--- Mismatched set and end locals
--- Extra setlocal in called batch
value2
2set1endvalue1
@pwd@\foobar\foodir3
Finished:
value2
@pwd@\foobar\foodir2
value1
@pwd@\foobar
--- Extra endlocal in called batch
value2
value2
@pwd@\foobar\foodir2
value2
@pwd@\foobar\foodir2
Finished:
value2
@pwd@\foobar\foodir2
value1
@pwd@\foobar
--- endlocal in called function rather than batch pgm is ineffective
2
2
1
2
1
2
1
1
------------ Testing Errorlevel ------------
1
errorlevel just right, good
errorlevel with leading zero just right, good
errorlevel with negative number OK
abc0def@or_broken@abc1def
errorlevel zero, good@or_broken@errorlevel nonzero, bad
7 should be 7
7 should still be 7
------------ Testing GOTO ------------
goto with no leading space worked
goto with a leading space worked
goto with a leading tab worked
------------ Testing PATH ------------
PATH=original
PATH=try2
PATH=try3
------------ Testing combined CALLs/GOTOs ------------