Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lorenzo Ferrillo
wine
Commits
9b79fd57
Commit
9b79fd57
authored
13 years ago
by
Frédéric Delanoy
Committed by
Alexandre Julliard
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
cmd/tests: Add variable substitution tests.
parent
c85be8ae
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
programs/cmd/tests/test_builtins.cmd
+110
-0
110 additions, 0 deletions
programs/cmd/tests/test_builtins.cmd
programs/cmd/tests/test_builtins.cmd.exp
+62
-0
62 additions, 0 deletions
programs/cmd/tests/test_builtins.cmd.exp
with
172 additions
and
0 deletions
programs/cmd/tests/test_builtins.cmd
+
110
−
0
View file @
9b79fd57
...
...
@@ -227,6 +227,116 @@ echo '%VAR:~-2,-4%'
echo
%VAR
:
~-
3
,-
2
%
set
VAR
=
echo
------------
Testing
variable
substitution
--------------
echo
...in
FOR
variables
for
%%i
in
(
"A B"
C
)
do
echo
%%i
rem quotes removal
for
%%i
in
(
"A B"
C
)
do
echo
'
%%~i
'
rem fully qualified path
for
%%f
in
(
"C D"
E
)
do
echo
%%~ff
rem drive letter
for
%%i
in
(
"F G"
H
)
do
echo
%%~di
rem path
for
%%d
in
(
"I J"
K
)
do
echo
%%~pd
rem filename
for
%%i
in
(
"L M"
N
)
do
echo
%%~ni
rem file extension
for
%%i
in
(
"O. P.OOL"
Q
.TABC
hello
)
do
echo
'
%%~xi
'
rem path with short path names
for
%%I
in
(
"R S"
T
ABCDEFGHIJK
.LMNOP
)
do
echo
'
%%~sI
'
rem file attribute
for
%%i
in
(
"U V"
W
)
do
echo
'
%%~ai
'
echo
foo
>
foo
for
%%i
in
(
foo
)
do
echo
'
%%~ai
'
del
foo
rem file date/time
rem Not fully testable, until we can grep dir's output to get foo's creation time in an envvar...
for
%%i
in
(
"a b"
c
)
do
echo
'
%%~ti
'
rem file size
rem Similar issues as above
for
%%i
in
(
"a b"
c
)
do
echo
'
%%~zi
'
rem combined options
for
%%i
in
(
"d e"
f
)
do
echo
%%~dpi
for
%%i
in
(
"g h"
i
)
do
echo
%%~sdi
for
%%i
in
(
"g h"
i
)
do
echo
%%~dsi
for
%%i
in
(
"j k"
l
.eh
)
do
echo
'
%%~xsi
'
echo
...in
parameters
for
%%i
in
(
"A B"
C
)
do
call
:echoFun
%%i
rem quotes removal
for
%%i
in
(
"A B"
C
)
do
call
:echoFunQ
%%i
rem fully qualified path
for
%%f
in
(
"C D"
E
)
do
call
:echoFunF
%%f
rem drive letter
for
%%i
in
(
"F G"
H
)
do
call
:echoFunD
%%i
rem path
for
%%d
in
(
"I J"
K
)
do
call
:echoFunP
%%d
rem filename
for
%%i
in
(
"L M"
N
)
do
call
:echoFunN
%%i
rem file extension
for
%%i
in
(
"O. P.OOL"
Q
.TABC
hello
)
do
call
:echoFunX
%%i
rem path with short path names
for
%%I
in
(
"R S"
T
ABCDEFGHIJK
.LMNOP
)
do
call
:echoFunS
%%I
rem NT4 aborts whole script execution when encountering ~a, ~t and ~z substitutions, preventing full testing
rem combined options
for
%%i
in
(
"d e"
f
)
do
call
:echoFunDP
%%i
for
%%i
in
(
"g h"
i
)
do
call
:echoFunSD
%%i
for
%%i
in
(
"g h"
i
)
do
call
:echoFunDS
%%i
for
%%i
in
(
"j k"
l
.eh
)
do
call
:echoFunXS
%%i
goto
:endEchoFuns
:echoFun
echo
%
1
goto
:eof
:echoFunQ
echo
'
%
~1'
goto
:eof
:echoFunF
echo
%~f1
goto
:eof
:echoFunD
echo
%~d1
goto
:eof
:echoFunP
echo
%~p1
goto
:eof
:echoFunN
echo
%~n1
goto
:eof
:echoFunX
echo
'
%~x1
'
goto
:eof
:echoFunS
rem some NT4 workaround
set
VAR
=
'
%~s1
'
echo
%VAR%
set
VAR
=
goto
:eof
:echoFunDP
echo
%~dp1
goto
:eof
:echoFunSD
echo
%~sd1
goto
:eof
:echoFunDS
echo
%~ds1
goto
:eof
:echoFunXS
echo
'
%~xs1
'
goto
:eof
:endEchoFuns
echo
------------
Testing
variable
delayed
expansion
--------------
rem NT4 doesn't support this
echo
...default
mode
(
load
-time
expansion
)
...
...
This diff is collapsed.
Click to expand it.
programs/cmd/tests/test_builtins.cmd.exp
+
62
−
0
View file @
9b79fd57
...
...
@@ -213,6 +213,68 @@ ert@or_broken@qwerty
e@or_broken@qwerty
''@or_broken@'qwerty'
r@or_broken@qwerty
------------ Testing variable substitution --------------
...in FOR variables
@todo_wine@"A B"
C
'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'
...in parameters
@todo_wine@"A B"
C
@todo_wine@'A B'@or_broken@''
'C'@or_broken@''
@todo_wine@@pwd@\C D
@pwd@\E
@drive@
@drive@
@path@
@path@
@todo_wine@L M
N
@todo_wine@'.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@''
@drive@@path@
@drive@@path@
@drive@
@drive@
@drive@
@drive@
''
'.eh'@or_broken@''
------------ Testing variable delayed expansion --------------
...default mode (load-time expansion)
foo
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment