aboutsummaryrefslogtreecommitdiff
path: root/unit-tests/test/script
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2016-10-26 12:32:46 +0300
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 09:26:36 +0200
commit5daf46f700217521e8ba90c4be0e0369105544df (patch)
tree5ef8e2102aebd0383c1f000512151571c6edb38d /unit-tests/test/script
parent43378e3827fd0d17325646c40c76bab9db1da19a (diff)
Add support of file redirects to testscript runner
Diffstat (limited to 'unit-tests/test/script')
-rw-r--r--unit-tests/test/script/lexer/buildfile3
-rw-r--r--unit-tests/test/script/lexer/command-line.test107
-rw-r--r--unit-tests/test/script/lexer/script-line.test68
-rw-r--r--unit-tests/test/script/parser/buildfile3
-rw-r--r--unit-tests/test/script/parser/redirect.test5
5 files changed, 184 insertions, 2 deletions
diff --git a/unit-tests/test/script/lexer/buildfile b/unit-tests/test/script/lexer/buildfile
index fab61b6..30f6b9f 100644
--- a/unit-tests/test/script/lexer/buildfile
+++ b/unit-tests/test/script/lexer/buildfile
@@ -8,6 +8,7 @@ import libs = libbutl%lib{butl}
src = token lexer diagnostics utility variable name test/script/{token lexer}
exe{driver}: cxx{driver} ../../../../build2/cxx{$src} $libs \
-test{script-line first-token second-token variable-line variable comment}
+test{script-line command-line first-token second-token variable-line variable \
+ comment}
include ../../../../build2/
diff --git a/unit-tests/test/script/lexer/command-line.test b/unit-tests/test/script/lexer/command-line.test
new file mode 100644
index 0000000..765b59a
--- /dev/null
+++ b/unit-tests/test/script/lexer/command-line.test
@@ -0,0 +1,107 @@
+test.arguments += command-line
+
+$* <:"0<+" >>EOO # in-pass-redirect
+'0'
+<+
+EOO
+
+$* <:"0 <+" >>EOO # arg-in-pass-redirect
+'0 '
+<+
+EOO
+
+$* <:"1>+" >>EOO # out-pass-redirect
+'1'
+>+
+EOO
+
+$* <:"1 >+" >>EOO # arg-out-pass-redirect
+'1 '
+>+
+EOO
+
+$* <:"0<-" >>EOO # in-null-redirect
+'0'
+<-
+EOO
+
+$* <:"0 <-" >>EOO # arg-in-null-redirect
+'0 '
+<-
+EOO
+
+$* <:"1>-" >>EOO # out-null-redirect
+'1'
+>-
+EOO
+
+$* <:"1 >-" >>EOO # arg-out-null-redirect
+'1 '
+>-
+EOO
+
+$* <:"0<a b" >>EOO # in-str-redirect
+'0'
+<
+'a b'
+EOO
+
+$* <:"1>a b" >>EOO # out-str-redirect
+'1'
+>
+'a b'
+EOO
+
+$* <:"0<:a b" >>EOO # in-str-nn-redirect
+'0'
+<:
+'a b'
+EOO
+
+$* <:"1>:a b" >>EOO # out-str-nn-redirect
+'1'
+>:
+'a b'
+EOO
+
+$* <:"0<<E O I" >>EOO # in-doc-redirect
+'0'
+<<
+'E O I'
+EOO
+
+$* <:"1>>E O O" >>EOO # out-doc-redirect
+'1'
+>>
+'E O O'
+EOO
+
+$* <:"0<<:E O I" >>EOO # in-doc-nn-redirect
+'0'
+<<:
+'E O I'
+EOO
+
+$* <:"1>>:E O O" >>EOO # out-doc-nn-redirect
+'1'
+>>:
+'E O O'
+EOO
+
+$* <:"0<<<a b" >>EOO # in-file-redirect
+'0'
+<<<
+'a b'
+EOO
+
+$* <:"1>>>a b" >>EOO # out-file-redirect
+'1'
+>>>
+'a b'
+EOO
+
+$* <:"1>>>&a b" >>EOO # out-file-app-redirect
+'1'
+>>>&
+'a b'
+EOO
diff --git a/unit-tests/test/script/lexer/script-line.test b/unit-tests/test/script/lexer/script-line.test
index b4fe3ef..a217591 100644
--- a/unit-tests/test/script/lexer/script-line.test
+++ b/unit-tests/test/script/lexer/script-line.test
@@ -16,3 +16,71 @@ $* <";" >>EOO # semi-only
;
<newline>
EOO
+
+$* <"cmd <+ 1>+" >>EOO # pass-redirect
+'cmd'
+<+
+'1'
+>+
+<newline>
+EOO
+
+$* <"cmd <- 1>-" >>EOO # null-redirect
+'cmd'
+<-
+'1'
+>-
+<newline>
+EOO
+
+$* <"cmd <a 1>b" >>EOO # str-redirect
+'cmd'
+<
+'a'
+'1'
+>
+'b'
+<newline>
+EOO
+
+$* <"cmd <:a 1>:b" >>EOO # str-nn-redirect
+'cmd'
+<:
+'a'
+'1'
+>:
+'b'
+<newline>
+EOO
+
+$* <"cmd <<EOI 1>>EOO" >>EOO # doc-redirect
+'cmd'
+<<
+'EOI'
+'1'
+>>
+'EOO'
+<newline>
+EOO
+
+$* <"cmd <<:EOI 1>>:EOO" >>EOO # doc-nn-redirect
+'cmd'
+<<:
+'EOI'
+'1'
+>>:
+'EOO'
+<newline>
+EOO
+
+$* <"cmd <<<in >>>out 2>>>&err" >>EOO # file-redirect
+'cmd'
+<<<
+'in'
+>>>
+'out'
+'2'
+>>>&
+'err'
+<newline>
+EOO
diff --git a/unit-tests/test/script/parser/buildfile b/unit-tests/test/script/parser/buildfile
index 18acd20..b053971 100644
--- a/unit-tests/test/script/parser/buildfile
+++ b/unit-tests/test/script/parser/buildfile
@@ -11,6 +11,7 @@ filesystem config/{utility init operation} dump types-parsers \
test/{target script/{token lexer parser script}}
exe{driver}: cxx{driver} ../../../../build2/cxx{$src} $libs \
-test{pre-parse expansion here-document command-re-parse scope setup-teardown}
+test{pre-parse expansion redirect here-document command-re-parse scope \
+ setup-teardown}
include ../../../../build2/
diff --git a/unit-tests/test/script/parser/redirect.test b/unit-tests/test/script/parser/redirect.test
new file mode 100644
index 0000000..83b40cd
--- /dev/null
+++ b/unit-tests/test/script/parser/redirect.test
@@ -0,0 +1,5 @@
+$* <<EOI >>EOO # file
+cmd 0<<<a 1>>>b 2>>>&c
+EOI
+cmd <<<a >>>b 2>>>&c
+EOO