https://git.reactos.org/?p=reactos.git;a=commitdiff;h=988f8bd2f6568c6d390aa…
commit 988f8bd2f6568c6d390aa74a7e4c70980cebf046
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Mon Jul 27 19:16:45 2020 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Wed Aug 19 20:35:55 2020 +0200
[CMD_ROSTEST] Add tests for the command echoer.
---
modules/rostests/win32/cmd/rsrc.rc | 6 +
modules/rostests/win32/cmd/test_echoer_parser.cmd | 101 +++++++++++++++
.../rostests/win32/cmd/test_echoer_parser.cmd.exp | 138 +++++++++++++++++++++
3 files changed, 245 insertions(+)
diff --git a/modules/rostests/win32/cmd/rsrc.rc b/modules/rostests/win32/cmd/rsrc.rc
index 7fd54341dff..7196b345f36 100644
--- a/modules/rostests/win32/cmd/rsrc.rc
+++ b/modules/rostests/win32/cmd/rsrc.rc
@@ -22,3 +22,9 @@ test_builtins.cmd TESTCMD "test_builtins.cmd"
/* @makedep: test_builtins.cmd.exp */
test_builtins.cmd.exp TESTOUT "test_builtins.cmd.exp"
+
+/* @makedep: test_echoer_parser.cmd */
+test_echoer_parser.cmd TESTCMD "test_echoer_parser.cmd"
+
+/* @makedep: test_echoer_parser.cmd.exp */
+test_echoer_parser.cmd.exp TESTOUT "test_echoer_parser.cmd.exp"
diff --git a/modules/rostests/win32/cmd/test_echoer_parser.cmd
b/modules/rostests/win32/cmd/test_echoer_parser.cmd
new file mode 100644
index 00000000000..85d20ad9508
--- /dev/null
+++ b/modules/rostests/win32/cmd/test_echoer_parser.cmd
@@ -0,0 +1,101 @@
+::
+:: Diverse tests for the CMD echoer and parser.
+::
+@echo off
+setlocal enableextensions
+
+
+::
+:: Simple tests for the CMD echoer.
+::
+echo --------- Testing CMD echoer ---------
+@echo on
+
+if 1==1 echo j1|(echo j2) else echo j3
+
+(echo a 1>&2|echo a 1>&2) 2>&1
+
+echo 1
+@echo 2
+@@echo 3
+@@@echo 4
+
+:echo x1
+::echo x2
+@:echo y1
+@::echo y2
+@:::echo y3
+
+@@:echo z1
+@@::echo z2
+
+foobar
+echo
+foobar parameter
+echo parameter
+
+toto>NUL
+toto> NUL
+toto >NUL
+toto > NUL
+
+toto>NUL 2>&1
+toto> NUL 2>&1
+toto >NUL 2>&1
+toto > NUL 2>&1
+
+a&b
+a& b
+a &b
+a & b
+
+a||b
+a|| b
+a ||b
+a || b
+
+a&&b
+a&& b
+a &&b
+a && b
+
+:: a|b
+:: a| b
+:: a |b
+:: a | b
+
+if 1==1 (echo lol) else (echo boom)
+
+if 1==1 (
+echo lol
+) else (
+echo boom
+)
+
+for /l %%l in (1,1,5) do (echo %%l)
+
+for /l %%l in (1,1,5) do (
+echo %%l
+)
+
+for /l %%l in (1,1,5) do (@@@echo %%l)
+
+if 1==1 @echo hi
+if 1==1 (@echo heh)
+if 1==0 (@echo lol) else @echo better
+if 1==0 (@echo lol) else (@echo better2)
+
+(a)
+(a b)
+
+:: An empty parenthesized block is considered to be an error.
+:: ()
+
+
+@echo off
+
+::
+:: Finished!
+::
+echo --------- Finished --------------
+goto :EOF
diff --git a/modules/rostests/win32/cmd/test_echoer_parser.cmd.exp
b/modules/rostests/win32/cmd/test_echoer_parser.cmd.exp
new file mode 100644
index 00000000000..b582b62722f
--- /dev/null
+++ b/modules/rostests/win32/cmd/test_echoer_parser.cmd.exp
@@ -0,0 +1,138 @@
+--------- Testing CMD echoer ---------
+
+@pwd@>if 1 == 1 echo j1 | (echo j2 ) else echo j3@space@
+j2@space@
+
+@pwd@>(echo a 1>&2 | echo a 1>&2 ) 2>&1@space@
+a@space@
+a@space@
+
+@pwd@>echo 1@space@
+1
+2
+3
+4
+
+@pwd@>foobar
+
+@pwd@>echo
+ECHO is on.
+
+@pwd@>foobar parameter@space@
+
+@pwd@>echo parameter@space@
+parameter
+
+@pwd@>toto1>NUL@space@
+
+@pwd@>toto1>NUL@space@
+
+@pwd@>toto 1>NUL@space@
+
+@pwd@>toto 1>NUL@space@
+
+@pwd@>toto1>NUL 2>&1@space@
+
+@pwd@>toto1>NUL 2>&1@space@
+
+@pwd@>toto 1>NUL 2>&1@space@
+
+@pwd@>toto 1>NUL 2>&1@space@
+
+@pwd@>a & b
+
+@pwd@>a & b
+
+@pwd@>a & b
+
+@pwd@>a & b
+
+@pwd@>a || b
+
+@pwd@>a || b
+
+@pwd@>a || b
+
+@pwd@>a || b
+
+@pwd@>a && b
+
+@pwd@>a && b
+
+@pwd@>a && b
+
+@pwd@>a && b
+
+@pwd@>if 1 == 1 (echo lol ) else (echo boom )@space@
+lol
+
+@pwd@>if 1 == 1 (echo lol ) else (echo boom )@space@
+lol
+
+@pwd@>for /L %l in (1 1 5) do (echo %l )@space@
+
+@pwd@>(echo 1 )@space@
+1
+
+@pwd@>(echo 2 )@space@
+2
+
+@pwd@>(echo 3 )@space@
+3
+
+@pwd@>(echo 4 )@space@
+4
+
+@pwd@>(echo 5 )@space@
+5
+
+@pwd@>for /L %l in (1 1 5) do (echo %l )@space@
+
+@pwd@>(echo 1 )@space@
+1
+
+@pwd@>(echo 2 )@space@
+2
+
+@pwd@>(echo 3 )@space@
+3
+
+@pwd@>(echo 4 )@space@
+4
+
+@pwd@>(echo 5 )@space@
+5
+
+@pwd@>for /L %l in (1 1 5) do ()@space@
+
+@pwd@>()@space@
+1
+
+@pwd@>()@space@
+2
+
+@pwd@>()@space@
+3
+
+@pwd@>()@space@
+4
+
+@pwd@>()@space@
+5
+
+@pwd@>if 1 == 1@space@
+hi
+
+@pwd@>if 1 == 1 ()@space@
+heh
+
+@pwd@>if 1 == 0 () else@space@
+better
+
+@pwd@>if 1 == 0 () else ()@space@
+better2
+
+@pwd@>(a)@space@
+
+@pwd@>(a b )@space@
+--------- Finished --------------