From 023d8d8b040d5fce821080b016b4ce25eb67550d Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 26 Oct 2016 21:22:10 +0300 Subject: Add support of merge redirect to testscript parser --- unit-tests/test/script/lexer/command-line.test | 12 +++++ unit-tests/test/script/lexer/script-line.test | 8 +++ unit-tests/test/script/parser/redirect.test | 71 ++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) (limited to 'unit-tests') diff --git a/unit-tests/test/script/lexer/command-line.test b/unit-tests/test/script/lexer/command-line.test index 765b59a..4a71d46 100644 --- a/unit-tests/test/script/lexer/command-line.test +++ b/unit-tests/test/script/lexer/command-line.test @@ -40,6 +40,18 @@ $* <:"1 >-" >>EOO # arg-out-null-redirect >- EOO +$* <:"1>&2" >>EOO # merge-redirect +'1' +>& +'2' +EOO + +$* <:"1 >&2" >>EOO # arg-merge-redirect +'1 ' +>& +'2' +EOO + $* <:"0>EOO # in-str-redirect '0' < diff --git a/unit-tests/test/script/lexer/script-line.test b/unit-tests/test/script/lexer/script-line.test index a217591..36d440c 100644 --- a/unit-tests/test/script/lexer/script-line.test +++ b/unit-tests/test/script/lexer/script-line.test @@ -33,6 +33,14 @@ $* <"cmd <- 1>-" >>EOO # null-redirect EOO +$* <"cmd 1>&2" >>EOO # merge-redirect +'cmd' +'1' +>& +'2' + +EOO + $* <"cmd b" >>EOO # str-redirect 'cmd' < diff --git a/unit-tests/test/script/parser/redirect.test b/unit-tests/test/script/parser/redirect.test index 83b40cd..3497fd9 100644 --- a/unit-tests/test/script/parser/redirect.test +++ b/unit-tests/test/script/parser/redirect.test @@ -3,3 +3,74 @@ cmd 0<<>>b 2>>>&c EOI cmd <<>>b 2>>>&c EOO + +$* <>EOO # out-merge1 +cmd 1>&2 +EOI +cmd >&2 +EOO + +$* <>EOO # out-merge2 +cmd 1>&2 2>&1 2>a +EOI +cmd >&2 2>a +EOO + +$* <>EOE != 0 # out-merge-fail1 +cmd 1>&a +EOI +testscript:1:8: error: invalid stdout merge redirect file descriptor 'a' + info: must be 2 +EOE + +$* <>EOE != 0 # out-merge-fail2 +cmd 1>&1 +EOI +testscript:1:8: error: invalid stdout merge redirect file descriptor '1' + info: must be 2 +EOE + +$* <>EOE != 0 # out-merge-fail3 +cmd 1>& +EOI +testscript:1:8: error: missing stdout file descriptor +EOE + +$* <>EOO # err-merge1 +cmd 2>&1 +EOI +cmd 2>&1 +EOO + +$* <>EOO # err-merge2 +cmd 1>&2 2>&1 >a +EOI +cmd >a 2>&1 +EOO + +$* <>EOE != 0 # err-merge-fail1 +cmd 2>&2 +EOI +testscript:1:8: error: invalid stderr merge redirect file descriptor '2' + info: must be 1 +EOE + +$* <>EOE != 0 # err-merge-fail2 +cmd 2>&2 +EOI +testscript:1:8: error: invalid stderr merge redirect file descriptor '2' + info: must be 1 +EOE + +$* <>EOE != 0 # err-merge-fail3 +cmd 2>& +EOI +testscript:1:8: error: missing stderr file descriptor +EOE + +$* <>EOE != 0 # merge-fail1 +cmd 1>&2 2>&1 +EOI +testscript:1:14: error: stdout and stderr merge redirects + info: should not be specified both +EOE -- cgit v1.1