Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
3803134f
Commit
3803134f
authored
Oct 11, 2012
by
Frédéric Delanoy
Committed by
Alexandre Julliard
Oct 11, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/tests: Add tests for command line parsing.
Adapted from original patch by Martin Wilck <mwilck@arcor.de>.
parent
0ab71a42
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
244 additions
and
0 deletions
+244
-0
test_cmdline.cmd
programs/cmd/tests/test_cmdline.cmd
+167
-0
test_cmdline.cmd.exp
programs/cmd/tests/test_cmdline.cmd.exp
+77
-0
No files found.
programs/cmd/tests/test_cmdline.cmd
View file @
3803134f
...
...
@@ -88,3 +88,170 @@ cmd.exe /c exit
cd ..
rd foobar /s /q
rem - Temporary batch files
echo @echo 0 > "say.bat"
echo @echo 1 > "say one.bat"
echo @echo 2 > "saytwo.bat"
echo @echo 3 > "say (3).bat"
echo @echo 4 > "say .bat"
echo ------ Testing invocation of batch files ----------
call say one
call "say one"
call "say"" one"
call "say one
call :setError 0
call say" one"
if errorlevel 2 echo error %ErrorLevel%
call say "one"
call :setError 0
call s"ay one
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
call s"aytwo
if errorlevel 2 echo error %ErrorLevel%
call say (3)
call "say (3)"
call :setError 0
call say" (3)"
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
call say" "(3) prints 4?!
if errorlevel 2 echo error %ErrorLevel%
echo ------ Testing invocation with CMD /C -------------
cmd /c say one
cmd /c "say one"
call :setError 0
cmd /c "say"" one"
if errorlevel 2 echo error %ErrorLevel%
cmd /c "say one
call :setError 0
cmd /c say" one"
if errorlevel 2 echo error %ErrorLevel%
cmd /c say "one"
call :setError 0
cmd /c s"ay one
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
cmd /c s"aytwo
if errorlevel 2 echo error %ErrorLevel%
cmd /c say (3)
call :setError 0
cmd /c say" (3)"
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
cmd /c say" "(3) prints 4?!
if errorlevel 2 echo error %ErrorLevel%
echo ---------- Testing CMD /C quoting -----------------
cmd /c @echo "hi"
call :setError 0
cmd /c say" "one
if errorlevel 2 echo error %ErrorLevel%
cmd /c @echo "\"\\"\\\"\\\\" "\"\\"\\\"\\\\"
rem ---- all 5 conditions met, quotes preserved
cmd /c "say one"
rem cond 1 - /s
cmd /s/c "say one"
cmd /s/c ""say one""
rem cond 2 - not 2 quotes
cmd /c "say one
call :setError 0
cmd /c "say"" one"
if errorlevel 2 echo error %ErrorLevel%
rem cond 3 - special char - first test fails on Vista, W2K8!
cmd /c "say (3)"
cmd /c ""say (3)""
rem cond 4 - no spaces (quotes make no difference here)
cmd /c saytwo
cmd /c "saytwo"
cmd /c "saytwo
rem cond 5 - string between quotes must be name of executable
cmd /c "say five"
echo @echo 5 >"say five.bat"
cmd /c "say five"
echo ------- Testing CMD /C qualifier treatment ------------
rem no need for space after /c
cmd /csay one
cmd /c"say one"
rem ignore quote before qualifier
rem FIXME the next command in wine starts a sub-CMD
echo THIS FAILS: cmd "/c"say one
rem ignore anything before /c
rem FIXME the next command in wine starts a sub-CMD
echo THIS FAILS: cmd ignoreme/c say one
echo --------- Testing special characters --------------
echo @echo amp > "say&.bat"
call say&
echo @echo ( > "say(.bat"
call say(
echo @echo ) > "say).bat"
call say)
echo @echo [ > "say[.bat"
call say[
echo @echo ] > "say].bat"
call say]
echo @echo { > "say{.bat"
call say{
echo @echo } > "say}.bat"
call say}
echo @echo = > "say=.bat"
call say=
echo @echo sem > "say;.bat"
call say;
setlocal DisableDelayedExpansion
echo @echo ! > "say!.bat"
call say!
endlocal
setlocal EnableDelayedExpansion
call say!
endlocal
echo @echo %%%% > "say%%.bat"
call say%%
echo @echo ' > "say'.bat"
call say'
echo @echo + > "say+.bat"
call say+
echo @echo com > "say,.bat"
call say,
echo @echo ` > "say`.bat"
call say'
echo @echo ~ > "say~.bat"
call say~
echo --------- Testing parameter passing --------------
echo @echo 1:%%1,2:%%2 > tell.bat
call tell 1
call tell (1)
call tell 1(2)
call :setError 0
call tell(1)
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
call tell((1))
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
call tell(1)(2)
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
call tell(1);,;(2)
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
call tell;1 2
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
call tell; 1, ;2
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
call tell;1;;2
if errorlevel 2 echo error %ErrorLevel%
call tell "p "1 p" "2
call tell p"1 p";2
del tell.bat say*.*
exit
:setError
exit /B %1
programs/cmd/tests/test_cmdline.cmd.exp
View file @
3803134f
...
...
@@ -45,3 +45,80 @@ one = %1
@todo_wine@var contents: 11
var=33@space@
99
------ Testing invocation of batch files ----------
0@space@
1@space@
@todo_wine@1@space@
1@space@
@todo_wine@1@space@
0@space@
@todo_wine@1@space@
@todo_wine@2@space@
0@space@
3@space@
@todo_wine@3@space@
@todo_wine@4@space@
------ Testing invocation with CMD /C -------------
0@space@
@todo_wine@1@space@
@todo_wine@0@space@
0@space@
@todo_wine@1@space@
0@space@
@todo_wine@1@space@
@todo_wine@2@space@
0@space@
@todo_wine@3@space@
@todo_wine@4@space@
---------- Testing CMD /C quoting -----------------
"hi"
@todo_wine@1@space@
"\"\\"\\\"\\\\"@space@"\"\\"\\\"\\\\"
@todo_wine@1@space@
0@space@
1@space@
0@space@
@todo_wine@0@space@
0@space@@or_broken@3@space@
3@space@
2@space@
2@space@
2@space@
0@space@
@todo_wine@5@space@
------- Testing CMD /C qualifier treatment ------------
0@space@
@todo_wine@1@space@
THIS FAILS: cmd "/c"say one
THIS FAILS: cmd ignoreme/c say one
--------- Testing special characters --------------
0@space@
@todo_wine@0@space@
)@space@
[@space@
]@space@
{@space@
}@space@
0@space@
@todo_wine@0@space@
!@space@
@todo_wine@0@space@@or_broken@!@space@
@todo_wine@0@space@
'@space@
+@space@
0@space@
'@space@
~@space@
--------- Testing parameter passing --------------
1:1,2:@space@
1:(1),2:@space@
1:1(2),2:@space@
@todo_wine@1:(1),2:@space@
@todo_wine@1:((1)),2:@space@
@todo_wine@1:(1)(2),2:@space@
@todo_wine@1:(1),2:(2)@space@
@todo_wine@1:1,2:2@space@
@todo_wine@1:1,2:2@space@
@todo_wine@1:1,2:2@space@
1:"p@space@"1,2:p"@space@"2@space@
1:p"1@space@p",2:2@space@
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment