From c55240fb05151cae046c75a793c164d72c988db2 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 6 Jan 2017 18:46:58 +0300 Subject: Tests cleanup (take 2) --- tests/test/script/builtin/rm.test | 188 +++-- tests/value/reverse.test | 110 +-- unit-tests/function/call.test | 3 - unit-tests/lexer/comment.test | 221 ++--- unit-tests/lexer/quoting.test | 145 ++-- .../test/script/lexer/command-expansion.test | 360 ++++++--- unit-tests/test/script/lexer/command-line.test | 311 ++++--- unit-tests/test/script/lexer/description-line.test | 20 +- unit-tests/test/script/lexer/first-token.test | 52 +- unit-tests/test/script/lexer/second-token.test | 36 +- unit-tests/test/script/lexer/variable-line.test | 16 +- unit-tests/test/script/lexer/variable.test | 102 ++- unit-tests/test/script/parser/cleanup.test | 39 +- unit-tests/test/script/parser/command-if.test | 891 +++++++++++---------- .../test/script/parser/command-re-parse.test | 7 +- unit-tests/test/script/parser/description.test | 720 ++++++++++------- unit-tests/test/script/parser/directive.test | 4 + unit-tests/test/script/parser/exit.test | 4 + unit-tests/test/script/parser/expansion.test | 11 +- unit-tests/test/script/parser/here-document.test | 4 + unit-tests/test/script/parser/here-string.test | 12 +- unit-tests/test/script/parser/include.test | 12 +- unit-tests/test/script/parser/pipe-expr.test | 4 + unit-tests/test/script/parser/pre-parse.test | 36 +- unit-tests/test/script/parser/redirect.test | 294 ++++--- unit-tests/test/script/parser/regex.test | 8 +- unit-tests/test/script/parser/scope-if.test | 681 ++++++++-------- unit-tests/test/script/parser/scope.test | 410 ++++++---- unit-tests/test/script/parser/setup-teardown.test | 126 ++- 29 files changed, 2754 insertions(+), 2073 deletions(-) diff --git a/tests/test/script/builtin/rm.test b/tests/test/script/builtin/rm.test index 915052a..cd4a922 100644 --- a/tests/test/script/builtin/rm.test +++ b/tests/test/script/builtin/rm.test @@ -6,102 +6,118 @@ : no-args : -: Removing with no arguments fails. -: -$c <'rm 2>"rm: missing file" == 1'; -$b - -: no-args-force -: -: Removing with no arguments succeeds with -f option. -: -$c <'rm -f'; -$b +{ + : fail + : + : Removing with no arguments fails. + : + $c <'rm 2>"rm: missing file" == 1'; + $b -: empty-path -: -: Removing an empty path fails. -: -$c <"rm: invalid path ''" == 1 -EOI -$b + : force + : + : Removing with no arguments succeeds with -f option. + : + $c <'rm -f'; + $b +} : file : -: Removing existing file succeeds. -: -$c <>~%EOE% == 1 -%rm: unable to remove '.+[/\\]test[/\\]rm[/\\]file-not-exists[/\\]test[/\\]1[/\\]a': .+% -EOE -EOI -$b + : not-exists + : + : Removing non-existing file fails. + : + $c <>~%EOE% == 1 + %rm: unable to remove '.+[/\\]test[/\\]rm[/\\]file[/\\]not-exists[/\\]test[/\\]1[/\\]a': .+% + EOE + EOI + $b -: file-not-exists-force -: -: Removing non-existing file succeeds with -f option. -: -$c <'rm -f a'; -$b + : not-exists-force + : + : Removing non-existing file succeeds with -f option. + : + $c <'rm -f a'; + $b +} : dir : -: Removing directory fails by default. -: -$c <"rm: '$normalize([path] $~/a)' is a directory" == 1 -EOI -$b +{ + : default + : + : Removing directory fails by default. + : + $c <"rm: '$normalize([path] $~/a)' is a directory" == 1 + EOI + $b -: dir-recursive -: -: Removing directory succeeds with -r option. -: -$c <"rm: '([string] $~)' contains test working directory '$~'" == 1 -EOI -$b + : scope + : + : Removing scope directory fails. + : + $c <"rm: '([string] $~)' contains test working directory '$~'" == 1 + EOI + $b +} -: outside-scope -: -: Removing path outside the testscript working directory fails. Need to use a -: path that unlikely exists (not to remove something useful). -: -: -$c <>~%EOE% == 1 -%rm: '.+[/\\]outside-scope[/\\]a[/\\]b[/\\]c' is out of working directory '.+[/\\]outside-scope[/\\]test'% -EOE -EOI -$b +: path +: +{ + : empty + : + : Removing an empty path fails. + : + $c <"rm: invalid path ''" == 1 + EOI + $b -: outside-scope-force -: -: Removing path outside the testscript working directory succeeds with -f -: option. Need to use a path that unlikely exists (not to remove something -: useful). -: -$c <'rm -f ../../a/b/c'; -$b + : outside-scope + : + : Removing path outside the testscript working directory fails. Need to use + : a path that unlikely exists (not to remove something useful). + : + : + $c <>~%EOE% == 1 + %rm: '.+[/\\]path[/\\]outside-scope[/\\]a[/\\]b[/\\]c' is out of working directory '.+[/\\]outside-scope[/\\]test'% + EOE + EOI + $b + + : outside-scope-force + : + : Removing path outside the testscript working directory succeeds with -f + : option. Need to use a path that unlikely exists (not to remove something + : useful). + : + $c <'rm -f ../../a/b/c'; + $b +} diff --git a/tests/value/reverse.test b/tests/value/reverse.test index 06de043..d667a9d 100644 --- a/tests/value/reverse.test +++ b/tests/value/reverse.test @@ -7,68 +7,76 @@ .include ../common.test -: name-dir +: name : -$* <>EOO -x = s/foo/bar/ -print ([string] $x) -print "$x" -print -e=$x -EOI -s/foo/bar/ -s/foo/bar/ --e=s/foo/bar/ -EOO +{ + : dir + : + $* <>EOO + x = s/foo/bar/ + print ([string] $x) + print "$x" + print -e=$x + EOI + s/foo/bar/ + s/foo/bar/ + -e=s/foo/bar/ + EOO -: name-proj -: -$* <>EOO -print ([strings] foo%bar foo% %bar) -EOI -foo%bar foo% %bar -EOO + : proj + : + $* <>EOO + print ([strings] foo%bar foo% %bar) + EOI + foo%bar foo% %bar + EOO -: name-pair -: -$* <>EOO -print ([strings] foo@bar foo/@bar/ foo@ @bar @ "@@") -EOI -foo@bar foo/@bar/ foo@ @bar @ @@ -EOO + : pair + : + $* <>EOO + print ([strings] foo@bar foo/@bar/ foo@ @bar @ "@@") + EOI + foo@bar foo/@bar/ foo@ @bar @ @@ + EOO -: name-combined -: -$* <>EOO -print ([strings] x%foo@y%bar x%foo/@y%bar/) -EOI -x%foo@y%bar x%foo/@y%bar/ -EOO + : combined + : + $* <>EOO + print ([strings] x%foo@y%bar x%foo/@y%bar/) + EOI + x%foo@y%bar x%foo/@y%bar/ + EOO +} : dir-path : -$* <>"EOO" -x = [dir_path] foo/bar/ -print ([string] $x) -print "$x" -print "-I$x" -EOI -foo/bar/ -foo/bar --Ifoo/bar -EOO - -: dir-path-root -: -if ($cxx.target.class != windows) { - $* <>EOO - x = [dir_path] / + : rel + : + $* <>"EOO" + x = [dir_path] foo/bar/ print ([string] $x) print "$x" print "-I$x" EOI - / - / - -I/ + foo/bar/ + foo/bar + -Ifoo/bar EOO + + : root + : + if ($cxx.target.class != windows) + { + $* <>EOO + x = [dir_path] / + print ([string] $x) + print "$x" + print "-I$x" + EOI + / + / + -I/ + EOO + } } diff --git a/unit-tests/function/call.test b/unit-tests/function/call.test index c9ef49c..e17c247 100644 --- a/unit-tests/function/call.test +++ b/unit-tests/function/call.test @@ -109,14 +109,11 @@ $* <'$bogus([uint64] 123)' 2>>EOE != 0 buildfile:1:2: error: unmatched call to bogus(uint64) EOE -#\ -@@ TMP : print-call-2 : $* <'$bogus(abc, [uint64] 123)' 2>>EOE != 0 buildfile:1:2: error: unmatched call to bogus(, uint64) EOE -#\ : print-fovl : diff --git a/unit-tests/lexer/comment.test b/unit-tests/lexer/comment.test index 025b0a2..6840219 100644 --- a/unit-tests/lexer/comment.test +++ b/unit-tests/lexer/comment.test @@ -2,111 +2,138 @@ # copyright : Copyright (c) 2014-2017 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -# Single-line comments. +: single-line +: +{ + : only + : + $* <>:EOO + # comment + EOI + EOO -$* <>:EOO # single-only -# comment -EOI -EOO + : first + : + $* <>EOO + # comment + foo + EOI + 'foo' + + EOO -$* <>EOO # single-first -# comment -foo -EOI -'foo' - -EOO + : last + : + $* <>EOO + foo + # comment + EOI + 'foo' + + EOO -$* <>EOO # single-last -foo -# comment -EOI -'foo' - -EOO + : few + : + $* <>EOO + foo + # comment + # comment + EOI + 'foo' + + EOO -$* <>EOO # single-few -foo -# comment -# comment -EOI -'foo' - -EOO + : cont + : + $* <>EOO + foo + # comment\\ + bar + EOI + 'foo' + + 'bar' + + EOO -$* <>EOO # single-cont -foo -# comment\\ -bar -EOI -'foo' - -'bar' - -EOO + : same + : + $* <>EOO + foo # comment + bar # comment + EOI + 'foo' + + 'bar' + + EOO +} -$* <>EOO # single-same -foo # comment -bar # comment -EOI -'foo' - -'bar' - -EOO +: multi-line +: +{ + : only + : + $* <>:EOO + #\ + comment + comment + #\ + EOI + EOO -# Multi-line comments. -# + : empty + : + $* <>:EOO + #\ + #\ + EOI + EOO -$* <>:EOO # multi-only -#\ -comment -comment -#\ -EOI -EOO + : start-same + : + $* <>EOO + foo #\ + comment + comment + #\ + EOI + 'foo' + + EOO -$* <>:EOO # multi-empty -#\ -#\ -EOI -EOO + : end-same + : + $* <>EOO + #\ + comment + comment + foo #\ + bar + EOI + 'bar' + + EOO -$* <>EOO # multi-start-same -foo #\ -comment -comment -#\ -EOI -'foo' - -EOO + : end-not + : + $* <>EOO + #\ + comment + #\ not an end + foo #\ + bar + EOI + 'bar' + + EOO -$* <>EOO # multi-end-same -#\ -comment -comment -foo #\ -bar -EOI -'bar' - -EOO - -$* <>EOO # multi-end-not -#\ -comment -#\ not an end -foo #\ -bar -EOI -'bar' - -EOO - -$* <>EOE != 0 # multi-unterm -#\ -comment -EOI -stdin:3:1: error: unterminated multi-line comment -EOE + : unterm + : + $* <>EOE != 0 + #\ + comment + EOI + stdin:3:1: error: unterminated multi-line comment + EOE +} diff --git a/unit-tests/lexer/quoting.test b/unit-tests/lexer/quoting.test index 84818fc..a44d6af 100644 --- a/unit-tests/lexer/quoting.test +++ b/unit-tests/lexer/quoting.test @@ -11,81 +11,94 @@ $* <'foo' >>EOO EOO -: single-comp +: comp : -$* <":'foo':" >>EOO -: -'foo' [S/C] -: - -EOO +{ + : single + : + $* <":'foo':" >>EOO + : + 'foo' [S/C] + : + + EOO -: double-comp -: -$* <':"foo":' >>EOO -: -'foo' [D/C] -: - -EOO + : double + : + $* <':"foo":' >>EOO + : + 'foo' [D/C] + : + + EOO -: single-empty-comp -: -$* <"''" >>EOO -'' [S/C] - -EOO + : single-empty + : + $* <"''" >>EOO + '' [S/C] + + EOO -: double-empty-comp -: -$* <'""' >>EOO -'' [D/C] - -EOO + : double-empty + : + $* <'""' >>EOO + '' [D/C] + + EOO +} -: part-start-quoted -: Token start already quoted -: -$* <'"$foo"' >>EOO -'' [D/P] -$ [D/C] -'foo' [D/P] - -EOO +: part +{ + : quoted + { + : start + : Token start already quoted + : + $* <'"$foo"' >>EOO + '' [D/P] + $ [D/C] + 'foo' [D/P] + + EOO -: part-end-quoted -: Token end still quoted -: -$* <'"foo$"' >>EOO -'foo' [D/P] -$ [D/C] -'' [D/P] - -EOO + : end + : Token end still quoted + : + $* <'"foo$"' >>EOO + 'foo' [D/P] + $ [D/C] + '' [D/P] + + EOO + } -: part-start-unquoted -: Token starts with unquoted character -: -$* <'f"oo"' >>EOO -'foo' [D/P] - -EOO + : unquoted + { + : start + : Token starts with unquoted character + : + $* <'f"oo"' >>EOO + 'foo' [D/P] + + EOO -: part-unquoted -: Token continous with unquoted character -: -$* <'"fo"o' >>EOO -'foo' [D/P] - -EOO + : end + : Token continous with unquoted character + : + $* <'"fo"o' >>EOO + 'foo' [D/P] + + EOO -: part-unquoted-escape -: Token continous with unquoted escaped character -: -$* <'"fo"\"' >>EOO -'fo"' [D/P] - -EOO + : escape + : Token continous with unquoted escaped character + : + $* <'"fo"\"' >>EOO + 'fo"' [D/P] + + EOO + } +} : mixed : diff --git a/unit-tests/test/script/lexer/command-expansion.test b/unit-tests/test/script/lexer/command-expansion.test index f113846..faae29d 100644 --- a/unit-tests/test/script/lexer/command-expansion.test +++ b/unit-tests/test/script/lexer/command-expansion.test @@ -1,134 +1,230 @@ +# file : unit-tests/test/script/lexer/command-expansion.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + test.arguments = command-expansion -$* <:"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 - -$* <:"1>&2" >>EOO # merge-redirect -'1' ->& -'2' -EOO - -$* <:"1 >&2" >>EOO # arg-merge-redirect -'1 ' ->& -'2' -EOO - -$* <:"0>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<>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<<>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 - -$* <:"&file" >>EOO # cleanup-always -& -'file' -EOO - -$* <:"&?file" >>EOO # cleanup-maybe -&? -'file' -EOO - -$* <:"&!file" >>EOO # cleanup-never -&! -'file' -EOO +: pass-redirect +: +{ + : in + : + $* <:"0<+" >>EOO + '0' + <+ + EOO + + : arg-in + : + $* <:"0 <+" >>EOO + '0 ' + <+ + EOO + + : out + : + $* <:"1>+" >>EOO + '1' + >+ + EOO + + : arg-out + : + $* <:"1 >+" >>EOO + '1 ' + >+ + EOO +} + +: null-redirect +: +{ + : in + : + $* <:"0<-" >>EOO + '0' + <- + EOO + + : arg-in + : + $* <:"0 <-" >>EOO + '0 ' + <- + EOO + + : out + : + $* <:"1>-" >>EOO + '1' + >- + EOO + + : arg-out + : + $* <:"1 >-" >>EOO + '1 ' + >- + EOO +} + +: merge-redirect +: +{ + : out + : + $* <:"1>&2" >>EOO + '1' + >& + '2' + EOO + + : arg-out + : + $* <:"1 >&2" >>EOO + '1 ' + >& + '2' + EOO +} + +: str-redirect +: +{ + : in + : + { + : newline + : + $* <:"0>EOO + '0' + < + 'a b' + EOO + + : no-newline + : + $* <:"0<:a b" >>EOO + '0' + <: + 'a b' + EOO + } + + : out + : + { + : newline + : + $* <:"1>a b" >>EOO + '1' + > + 'a b' + EOO + + : no-newline + : + $* <:"1>:a b" >>EOO + '1' + >: + 'a b' + EOO + } +} + +: doc-redirect +: +{ + : in + : + { + : newline + : + $* <:"0<>EOO + '0' + << + 'E O I' + EOO + + : no-newline + : + $* <:"0<<:E O I" >>EOO + '0' + <<: + 'E O I' + EOO + } + + : out + : + { + : newline + : + $* <:"1>>E O O" >>EOO + '1' + >> + 'E O O' + EOO + + : no-newline + : + $* <:"1>>:E O O" >>EOO + '1' + >>: + 'E O O' + EOO + } +} + +: file-redirect +: +{ + : in + : + $* <:"0<<>EOO + '0' + <<< + 'a b' + EOO + + : out + : + $* <:"1>>>a b" >>EOO + '1' + >>> + 'a b' + EOO + + : out-app + : + $* <:"1>>>&a b" >>EOO + '1' + >>>& + 'a b' + EOO +} + +: cleanup +: +{ + : always + : + $* <:"&file" >>EOO + & + 'file' + EOO + + : maybe + : + $* <:"&?file" >>EOO + &? + 'file' + EOO + + : never + : + $* <:"&!file" >>EOO + &! + 'file' + EOO +} diff --git a/unit-tests/test/script/lexer/command-line.test b/unit-tests/test/script/lexer/command-line.test index 0040cfe..8a73b3d 100644 --- a/unit-tests/test/script/lexer/command-line.test +++ b/unit-tests/test/script/lexer/command-line.test @@ -1,134 +1,187 @@ +# file : unit-tests/test/script/lexer/command-line.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + test.arguments = command-line -$* <"cmd;" >>EOO # semi -'cmd' -; - -EOO - -$* <"cmd ;" >>EOO # semi-separated -'cmd' -; - -EOO - -$* <";" >>EOO # semi-only -; - -EOO - -$* <"cmd: dsc" >>EOO # colon -'cmd' +: semi +{ + : immediate + : + $* <"cmd;" >>EOO + 'cmd' + ; + + EOO + + : separated + : + $* <"cmd ;" >>EOO + 'cmd' + ; + + EOO + + : only + : + $* <";" >>EOO + ; + + EOO +} + +: colon : -'dsc' - -EOO - -$* <"cmd :dsc" >>EOO # colon-separated -'cmd' +{ + : immediate + : + $* <"cmd: dsc" >>EOO + 'cmd' + : + 'dsc' + + EOO + + : separated + : + $* <"cmd :dsc" >>EOO + 'cmd' + : + 'dsc' + + EOO + + : only + : + $* <":" >>EOO + : + + EOO +} + +: redirect : -'dsc' - -EOO - -$* <":" >>EOO # colon-only +{ + : pass + : + $* <"cmd <+ 1>+" >>EOO + 'cmd' + <+ + '1' + >+ + + EOO + + : null + : + $* <"cmd <- 1>-" >>EOO + 'cmd' + <- + '1' + >- + + EOO + + : merge + : + $* <"cmd 1>&2" >>EOO + 'cmd' + '1' + >& + '2' + + EOO + + : str + : + $* <"cmd b" >>EOO + 'cmd' + < + 'a' + '1' + > + 'b' + + EOO + + : str-nn + : + $* <"cmd <:a 1>:b" >>EOO + 'cmd' + <: + 'a' + '1' + >: + 'b' + + EOO + + : doc + : + $* <"cmd <>EOO" >>EOO + 'cmd' + << + 'EOI' + '1' + >> + 'EOO' + + EOO + + : doc-nn + : + $* <"cmd <<:EOI 1>>:EOO" >>EOO + 'cmd' + <<: + 'EOI' + '1' + >>: + 'EOO' + + EOO + + : file + : + $* <"cmd <<>>out 2>>>&err" >>EOO + 'cmd' + <<< + 'in' + >>> + 'out' + '2' + >>>& + 'err' + + EOO +} + +: cleanup : - -EOO - -$* <"cmd <+ 1>+" >>EOO # pass-redirect -'cmd' -<+ -'1' ->+ - -EOO - -$* <"cmd <- 1>-" >>EOO # null-redirect -'cmd' -<- -'1' ->- - -EOO - -$* <"cmd 1>&2" >>EOO # merge-redirect -'cmd' -'1' ->& -'2' - -EOO - -$* <"cmd b" >>EOO # str-redirect -'cmd' -< -'a' -'1' -> -'b' - -EOO - -$* <"cmd <:a 1>:b" >>EOO # str-nn-redirect -'cmd' -<: -'a' -'1' ->: -'b' - -EOO - -$* <"cmd <>EOO" >>EOO # doc-redirect -'cmd' -<< -'EOI' -'1' ->> -'EOO' - -EOO - -$* <"cmd <<:EOI 1>>:EOO" >>EOO # doc-nn-redirect -'cmd' -<<: -'EOI' -'1' ->>: -'EOO' - -EOO - -$* <"cmd <<>>out 2>>>&err" >>EOO # file-redirect -'cmd' -<<< -'in' ->>> -'out' -'2' ->>>& -'err' - -EOO - -$* <"cmd &file" >>EOO # cleanup-always -'cmd' -& -'file' - -EOO - -$* <"cmd &?file" >>EOO # cleanup-maybe -'cmd' -&? -'file' - -EOO - -$* <"cmd &!file" >>EOO # cleanup-never -'cmd' -&! -'file' - -EOO +{ + : always + : + $* <"cmd &file" >>EOO + 'cmd' + & + 'file' + + EOO + + : maybe + : + $* <"cmd &?file" >>EOO + 'cmd' + &? + 'file' + + EOO + + : never + : + $* <"cmd &!file" >>EOO + 'cmd' + &! + 'file' + + EOO +} diff --git a/unit-tests/test/script/lexer/description-line.test b/unit-tests/test/script/lexer/description-line.test index 0f70e77..6b160c0 100644 --- a/unit-tests/test/script/lexer/description-line.test +++ b/unit-tests/test/script/lexer/description-line.test @@ -1,20 +1,32 @@ +# file : unit-tests/test/script/lexer/description-line.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + test.arguments = description-line -$* <" foo bar " >>EOO # full +: full +: +$* <" foo bar " >>EOO ' foo bar ' EOO -$* <" " >>EOO # space +: space +: +$* <" " >>EOO ' ' EOO -$* <"" >>EOO # empty +: empty +: +$* <"" >>EOO EOO -$* <:"foo" >>EOO 2>>EOE != 0 # eof +: eof +: +$* <:"foo" >>EOO 2>>EOE != 0 'foo' EOO stdin:1:4: error: expected newline at the end of description line diff --git a/unit-tests/test/script/lexer/first-token.test b/unit-tests/test/script/lexer/first-token.test index 8a6d39b..6044f53 100644 --- a/unit-tests/test/script/lexer/first-token.test +++ b/unit-tests/test/script/lexer/first-token.test @@ -1,68 +1,96 @@ +# file : unit-tests/test/script/lexer/first-token.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + # Note: this mode auto-expires after each token. # test.arguments = first-token -$* <"." >>EOO # dot +: dot +: +$* <"." >>EOO . EOO -$* <";" >>EOO # semi +: semi +: +$* <";" >>EOO ; EOO -$* <":" >>EOO # colon +: colon +: +$* <":" >>EOO : EOO -$* <"{" >>EOO # lcbrace +: lcbrace +: +$* <"{" >>EOO { EOO -$* <"}" >>EOO # rcbrace +: rcbrace +: +$* <"}" >>EOO } EOO -$* <"+foo" >>EOO # setup +: setup +: +$* <"+foo" >>EOO + 'foo' EOO -$* <"- foo" >>EOO # tdown +: tdown +: +$* <"- foo" >>EOO - 'foo' EOO -$* <"foo+bar" >>EOO # plus-leading +: plus-leading +: +$* <"foo+bar" >>EOO 'foo+bar' EOO -$* <"foo- x" >>EOO # minus-leading +: minus-leading +: +$* <"foo- x" >>EOO 'foo-' 'x' EOO -$* <"foo=" >>EOO # assign +: assign +: +$* <"foo=" >>EOO 'foo' '=' EOO -$* <"foo+=" >>EOO # append +: append +: +$* <"foo+=" >>EOO 'foo' '+=' EOO -$* <"foo=+" >>EOO # prepend +: prepend +: +$* <"foo=+" >>EOO 'foo' '=+' diff --git a/unit-tests/test/script/lexer/second-token.test b/unit-tests/test/script/lexer/second-token.test index 94cdf95..94ea441 100644 --- a/unit-tests/test/script/lexer/second-token.test +++ b/unit-tests/test/script/lexer/second-token.test @@ -1,47 +1,67 @@ +# file : unit-tests/test/script/lexer/second-token.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + # Note: this mode auto-expires after each token. # test.arguments = second-token -$* <";" >>EOO # semi +: semi +: +$* <";" >>EOO ; EOO -$* <":" >>EOO # colon +: colon +: +$* <":" >>EOO : EOO -$* <"=foo" >>EOO # assign +: assign +: +$* <"=foo" >>EOO = 'foo' EOO -$* <"+= foo" >>EOO # append +: append +: +$* <"+= foo" >>EOO += 'foo' EOO -$* <" =+ foo" >>EOO # prepend +: prepend +: +$* <" =+ foo" >>EOO =+ 'foo' EOO -$* <"foo=bar" >>EOO # assign-leading +: assign-leading +: +$* <"foo=bar" >>EOO 'foo=bar' EOO -$* <"foo+= bar" >>EOO # append-leading +: append-leading +: +$* <"foo+= bar" >>EOO 'foo+=' 'bar' EOO -$* <"foo =+bar" >>EOO # prepend-leading +: prepend-leading +: +$* <"foo =+bar" >>EOO 'foo' '=+bar' diff --git a/unit-tests/test/script/lexer/variable-line.test b/unit-tests/test/script/lexer/variable-line.test index 126fe54..c97981d 100644 --- a/unit-tests/test/script/lexer/variable-line.test +++ b/unit-tests/test/script/lexer/variable-line.test @@ -1,18 +1,28 @@ +# file : unit-tests/test/script/lexer/variable-line.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + test.arguments = variable-line -$* <"cmd;" >>EOO # semi +: semi +: +$* <"cmd;" >>EOO 'cmd' ; EOO -$* <"cmd ;" >>EOO # semi-separated +: semi-separated +: +$* <"cmd ;" >>EOO 'cmd' ; EOO -$* <";" >>EOO # semi-only +: semi-only +: +$* <";" >>EOO ; EOO diff --git a/unit-tests/test/script/lexer/variable.test b/unit-tests/test/script/lexer/variable.test index 0ecc6cc..15458f5 100644 --- a/unit-tests/test/script/lexer/variable.test +++ b/unit-tests/test/script/lexer/variable.test @@ -1,40 +1,70 @@ +# file : unit-tests/test/script/lexer/variable.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + # Test handling custom variable names ($*, $~, $NN). # test.arguments = variable -$* <"*" >>EOO -'*' - -EOO - -$* <"*abc" >>EOO -'*' -'abc' - -EOO - -$* <"~" >>EOO -'~' - -EOO - -$* <"~123" >>EOO -'~' -'123' - -EOO - -$* <"0" >>EOO -'0' - -EOO - -$* <"1abc" >>EOO -'1' -'abc' - -EOO - -$* <"10" 2>>EOE != 0 -stdin:1:1: error: multi-digit special variable name -EOE +: command +: +{ + : only + : + $* <"*" >>EOO + '*' + + EOO + + : followed + : + $* <"*abc" >>EOO + '*' + 'abc' + + EOO +} + +: working-dir +: +{ + : only + : + $* <"~" >>EOO + '~' + + EOO + + : followed + : + $* <"~123" >>EOO + '~' + '123' + + EOO +} + +: arg +: +{ + : only + : + $* <"0" >>EOO + '0' + + EOO + + : followed + : + $* <"1abc" >>EOO + '1' + 'abc' + + EOO + + : multi-digit + : + $* <"10" 2>>EOE != 0 + stdin:1:1: error: multi-digit special variable name + EOE +} diff --git a/unit-tests/test/script/parser/cleanup.test b/unit-tests/test/script/parser/cleanup.test index 76614e3..ac4d949 100644 --- a/unit-tests/test/script/parser/cleanup.test +++ b/unit-tests/test/script/parser/cleanup.test @@ -1,3 +1,7 @@ +# file : unit-tests/test/script/parser/cleanup.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + : always : $* <>EOO @@ -30,20 +34,25 @@ EOI testscript:1:6: error: empty cleanup path EOE -: missed-before-token -: Path missed before command next token +: missed-before : -$* <>EOE != 0 -cmd & >file -EOI -testscript:1:7: error: missing cleanup path -EOE +{ + : token + : + : Path missed before command next token + : + $* <>EOE != 0 + cmd & >file + EOI + testscript:1:7: error: missing cleanup path + EOE -: missed-before-end -: Test path missed before end of command -: -$* <>EOE != 0 -cmd & -EOI -testscript:1:6: error: missing cleanup path -EOE + : end + : Test path missed before end of command + : + $* <>EOE != 0 + cmd & + EOI + testscript:1:6: error: missing cleanup path + EOE +} diff --git a/unit-tests/test/script/parser/command-if.test b/unit-tests/test/script/parser/command-if.test index 4bbc016..ffe2c35 100644 --- a/unit-tests/test/script/parser/command-if.test +++ b/unit-tests/test/script/parser/command-if.test @@ -1,225 +1,506 @@ -: if-true -: -$* <>EOO -if true foo - cmd1 - cmd2 -end -EOI -? true foo -cmd1 -cmd2 -EOO +# file : unit-tests/test/script/parser/command-if.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file -: if-false +: if : -$* <>EOO -if false foo +{ + : true + : + $* <>EOO + if true foo + cmd1 + cmd2 + end + EOI + ? true foo cmd1 cmd2 -end -EOI -? false foo -EOO + EOO -: ifn-true -: -$* <>EOO -if! true foo + : false + : + $* <>EOO + if false foo + cmd1 + cmd2 + end + EOI + ? false foo + EOO + + : not-true + : + $* <>EOO + if! true foo + cmd1 + cmd2 + end + EOI + ? true foo + EOO + + : not-false + : + $* <>EOO + if! false foo + cmd1 + cmd2 + end + EOI + ? false foo cmd1 cmd2 -end -EOI -? true foo -EOO + EOO -: ifn-false -: -$* <>EOO -if! false foo - cmd1 - cmd2 -end -EOI -? false foo -cmd1 -cmd2 -EOO + : without-command + : + $* <>EOE != 0 + if + cmd + end + EOI + testscript:1:3: error: missing program + EOE + + : after-semi + : + $* -s <>EOO + cmd1; + if true + cmd2 + end + EOI + { + { + cmd1 + ? true + cmd2 + } + } + EOO -: elif-true -: -$* <>EOO -if false - cmd1 - cmd2 -elif true - cmd3 - cmd4 -end -EOI -? false -? true -cmd3 -cmd4 -EOO + : setup + : + $* -s <>EOO + +if true + cmd + end + EOI + { + ? true + cmd + } + EOO -: elif-false -: -$* <>EOO -if false - cmd1 - cmd2 -elif false - cmd3 - cmd4 -end -EOI -? false -? false -EOO + : tdown + : + $* -s <>EOO + -if true + cmd + end + EOI + { + ? true + cmd + } + EOO +} -: elifn-true +: elif : -$* <>EOO -if false - cmd1 - cmd2 -elif! true +{ + : true + : + $* <>EOO + if false + cmd1 + cmd2 + elif true + cmd3 + cmd4 + end + EOI + ? false + ? true cmd3 cmd4 -end -EOI -? false -? true -EOO + EOO -: elifn-false -: -$* <>EOO -if false - cmd1 - cmd2 -elif! false + : false + : + $* <>EOO + if false + cmd1 + cmd2 + elif false + cmd3 + cmd4 + end + EOI + ? false + ? false + EOO + + : not-true + : + $* <>EOO + if false + cmd1 + cmd2 + elif! true + cmd3 + cmd4 + end + EOI + ? false + ? true + EOO + + : not-false + : + $* <>EOO + if false + cmd1 + cmd2 + elif! false + cmd3 + cmd4 + end + EOI + ? false + ? false cmd3 cmd4 -end -EOI -? false -? false -cmd3 -cmd4 -EOO + EOO + + : without-if + : + $* <>EOE != 0 + cmd + elif true + cmd + end + EOI + testscript:2:1: error: 'elif' without preceding 'if' + EOE -: else-true + : not-without-if + : + $* <>EOE != 0 + cmd + elif! true + cmd + end + EOI + testscript:2:1: error: 'elif!' without preceding 'if' + EOE + + : after-else + : + $* <>EOE != 0 + if false + cmd + else + cmd + elif true + cmd + end + EOI + testscript:5:1: error: 'elif' after 'else' + EOE +} + +: else : -$* <>EOO -if false - cmd1 - cmd2 -else +{ + : true + : + $* <>EOO + if false + cmd1 + cmd2 + else + cmd3 + cmd4 + end + EOI + ? false cmd3 cmd4 -end -EOI -? false -cmd3 -cmd4 -EOO + EOO -: else-false -: -$* <>EOO -if true + : false + : + $* <>EOO + if true + cmd1 + cmd2 + else + cmd3 + cmd4 + end + EOI + ? true cmd1 cmd2 -else - cmd3 - cmd4 -end -EOI -? true -cmd1 -cmd2 -EOO + EOO -: if-chain -: -$* <>EOO -if false - cmd - cmd -elif false - cmd - cmd -elif false - cmd - cmd -elif true + : chain + : + $* <>EOO + if false + cmd + cmd + elif false + cmd + cmd + elif false + cmd + cmd + elif true + cmd1 + cmd2 + elif false + cmd + cmd + else + cmd + cmd + end + EOI + ? false + ? false + ? false + ? true cmd1 cmd2 -elif false - cmd - cmd -else - cmd + EOO + + : command-after + : + $* <>EOE != 0 + if true + cmd + else cmd + cmd + end + EOI + testscript:3:6: error: expected newline instead of 'cmd' + EOE + + : without-if + : + $* <>EOE != 0 cmd -end -EOI -? false -? false -? false -? true -cmd1 -cmd2 -EOO + else + cmd + end + EOI + testscript:2:1: error: 'else' without preceding 'if' + EOE -: nested-take -: -$* <>EOO -if true - cmd1 + : after-else + : + $* <>EOE != 0 if false cmd - elif false + else + cmd + else + cmd + end + EOI + testscript:5:1: error: 'else' after 'else' + EOE +} + +: end +{ + : without-if + : + $* <>EOE != 0 + cmd + end + EOI + testscript:2:1: error: 'end' without preceding 'if' + EOE + + : before + { + : semi + : + $* -s <>EOO + if true + cmd1 + end; + cmd2 + EOI + { + { + ? true + cmd1 + cmd2 + } + } + EOO + + : command + : + $* <>EOE != 0 if true cmd + end cmd + EOI + testscript:3:5: error: expected newline instead of 'cmd' + EOE + + : colon + : + $* -s <>EOO + if true + cmd1 + cmd2 + end : test + EOI + { + : id:test + { + ? true + cmd1 + cmd2 + } + } + EOO + } +} + +: nested +: +{ + : take + : + $* <>EOO + if true + cmd1 + if false + cmd + elif false + if true + cmd + end + else + cmd2 end - else - cmd2 + cmd3 end + EOI + ? true + cmd1 + ? false + ? false + cmd2 cmd3 -end -EOI -? true -cmd1 -? false -? false -cmd2 -cmd3 -EOO + EOO -: nested-skip -: -$* <>EOO -if false - cmd1 + : skip + : + $* <>EOO if false - cmd - elif false - if true + cmd1 + if false cmd + elif false + if true + cmd + end + else + cmd2 end + cmd3 else - cmd2 + cmd end - cmd3 -else + EOI + ? false cmd -end -EOI -? false -cmd -EOO + EOO +} + +: contained +{ + : semi + : + $* <>EOE != 0 + if + cmd; + cmd + end + EOI + testscript:2:3: error: ';' inside 'if' + EOE + + : colon-leading + : + $* <>EOE != 0 + if + : foo + cmd + end + EOI + testscript:2:3: error: description inside 'if' + EOE + + : colon-trailing + : + $* <>EOE != 0 + if + cmd : foo + end + EOI + testscript:2:3: error: description inside 'if' + EOE + + : eos + : + $* <>EOE != 0 + if + EOI + testscript:2:1: error: expected closing 'end' + EOE + + : scope + : + $* <>EOE != 0 + if + cmd + { + } + end + EOI + testscript:3:3: error: expected closing 'end' + EOE + + : setup + : + $* <>EOE != 0 + if + +cmd + end + EOI + testscript:2:3: error: setup command inside 'if' + EOE + + : tdown + : + $* <>EOE != 0 + if + -cmd + end + EOI + testscript:2:3: error: teardown command inside 'if' + EOE +} : line-index : @@ -255,258 +536,6 @@ EOI cmd foo EOO -: semi-inside -: -$* <>EOE != 0 -if - cmd; - cmd -end -EOI -testscript:2:3: error: ';' inside 'if' -EOE - -: colon-inside-leading -: -$* <>EOE != 0 -if - : foo - cmd -end -EOI -testscript:2:3: error: description inside 'if' -EOE - -: colon-inside-trailing -: -$* <>EOE != 0 -if - cmd : foo -end -EOI -testscript:2:3: error: description inside 'if' -EOE - -: eos-inside -: -$* <>EOE != 0 -if -EOI -testscript:2:1: error: expected closing 'end' -EOE - -: scope-inside -: -$* <>EOE != 0 -if - cmd - { - } -end -EOI -testscript:3:3: error: expected closing 'end' -EOE - -: setup-inside -: -$* <>EOE != 0 -if - +cmd -end -EOI -testscript:2:3: error: setup command inside 'if' -EOE - -: tdown-inside -: -$* <>EOE != 0 -if - -cmd -end -EOI -testscript:2:3: error: teardown command inside 'if' -EOE - -: if-without-command -: -$* <>EOE != 0 -if - cmd -end -EOI -testscript:1:3: error: missing program -EOE - -: command-after-else -: -$* <>EOE != 0 -if true - cmd -else cmd - cmd -end -EOI -testscript:3:6: error: expected newline instead of 'cmd' -EOE - -: command-after-end -: -$* <>EOE != 0 -if true - cmd -end cmd -EOI -testscript:3:5: error: expected newline instead of 'cmd' -EOE - -: elif-without-if -: -$* <>EOE != 0 -cmd -elif true - cmd -end -EOI -testscript:2:1: error: 'elif' without preceding 'if' -EOE - -: elifn-without-if -: -$* <>EOE != 0 -cmd -elif! true - cmd -end -EOI -testscript:2:1: error: 'elif!' without preceding 'if' -EOE - -: else-without-if -: -$* <>EOE != 0 -cmd -else - cmd -end -EOI -testscript:2:1: error: 'else' without preceding 'if' -EOE - -: end-without-if -: -$* <>EOE != 0 -cmd -end -EOI -testscript:2:1: error: 'end' without preceding 'if' -EOE - -: else-after-else -: -$* <>EOE != 0 -if false - cmd -else - cmd -else - cmd -end -EOI -testscript:5:1: error: 'else' after 'else' -EOE - -: elif-after-else -: -$* <>EOE != 0 -if false - cmd -else - cmd -elif true - cmd -end -EOI -testscript:5:1: error: 'elif' after 'else' -EOE - -: if-after-semi -: -$* -s <>EOO -cmd1; -if true - cmd2 -end -EOI -{ - { - cmd1 - ? true - cmd2 - } -} -EOO - -: setup-if -: -$* -s <>EOO -+if true - cmd -end -EOI -{ - ? true - cmd -} -EOO - -: tdown-if -: -$* -s <>EOO --if true - cmd -end -EOI -{ - ? true - cmd -} -EOO - -: semi-after-end -: -$* -s <>EOO -if true - cmd1 -end; -cmd2 -EOI -{ - { - ? true - cmd1 - cmd2 - } -} -EOO - -: colon-after-end -: -$* -s <>EOO -if true - cmd1 - cmd2 -end : test -EOI -{ - : id:test - { - ? true - cmd1 - cmd2 - } -} -EOO - : leading-and-trailing-description : $* <>EOE != 0 diff --git a/unit-tests/test/script/parser/command-re-parse.test b/unit-tests/test/script/parser/command-re-parse.test index 335ff69..657bf88 100644 --- a/unit-tests/test/script/parser/command-re-parse.test +++ b/unit-tests/test/script/parser/command-re-parse.test @@ -1,6 +1,9 @@ +# file : unit-tests/test/script/parser/command-re-parse.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file -# double-quote -# +: double-quote +: $* <>EOO x = cmd \">-\" "'<-'" $x diff --git a/unit-tests/test/script/parser/description.test b/unit-tests/test/script/parser/description.test index 16ba287..3e2bb7f 100644 --- a/unit-tests/test/script/parser/description.test +++ b/unit-tests/test/script/parser/description.test @@ -1,114 +1,414 @@ -$* <>EOO # id -: foo -cmd -EOI -: id:foo -cmd -EOO +# file : unit-tests/test/script/parser/description.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file -$* <>EOO # trail-id -cmd : foo -EOI -: id:foo -cmd -EOO +: id +: +{ + : lead + : + $* <>EOO + : foo + cmd + EOI + : id:foo + cmd + EOO -$* <>EOO # summary -: foo bar -cmd -EOI -: sm:foo bar -cmd -EOO + : trail + : + $* <>EOO + cmd : foo + EOI + : id:foo + cmd + EOO + + : dup + : Id uniqueness + : + { + : test + : + { + : test + : + $* <>EOE != 0 + : foo + cmd + : foo + cmd + EOI + testscript:3:1: error: duplicate id foo + testscript:1:1: info: previously used here + EOE + + : group + : + $* <>EOE != 0 + : foo + cmd + : foo + { + cmd + cmd + } + EOI + testscript:3:1: error: duplicate id foo + testscript:1:1: info: previously used here + EOE + + : derived + : + $* <>EOE != 0 + : 3 + cmd + cmd + EOI + testscript:3:1: error: duplicate id 3 + testscript:1:1: info: previously used here + EOE + } -$* <>EOO # trail-summary -cmd: foo bar -EOI -: sm:foo bar -cmd -EOO + : group + : + { + : test + : + $* <>EOE != 0 + : foo + { + cmd + cmd + } + : foo + cmd + EOI + testscript:6:1: error: duplicate id foo + testscript:1:1: info: previously used here + EOE + + : group + : + $* <>EOE != 0 + : foo + { + cmd + cmd + } + : foo + { + cmd + cmd + } + EOI + testscript:6:1: error: duplicate id foo + testscript:1:1: info: previously used here + EOE + + : derived + : + $* <>EOE != 0 + : 3 + cmd + { + cmd + cmd + } + EOI + testscript:3:1: error: duplicate id 3 + testscript:1:1: info: previously used here + EOE + } + } +} -$* <>EOO # id-summary -: foo-bar -: foo bar -cmd -EOI -: id:foo-bar -: sm:foo bar -cmd -EOO +: summary +{ + : lead + : + $* <>EOO + : foo bar + cmd + EOI + : sm:foo bar + cmd + EOO -# Initially assumed summary. -# -$* <>EOO # details-summary -: foo bar -: bar baz -cmd -EOI -: foo bar -: bar baz -cmd -EOO + : trail + : + $* <>EOO + cmd: foo bar + EOI + : sm:foo bar + cmd + EOO -# Initially assumed id and summary. -# -$* <>EOO # details-id-summary -: foo-bar -: bar baz -: baz fox -cmd -EOI -: foo-bar -: bar baz -: baz fox -cmd -EOO + : id + : + $* <>EOO + : foo-bar + : foo bar + cmd + EOI + : id:foo-bar + : sm:foo bar + cmd + EOO +} -$* <>EOO # id-details -: foo-bar +: details +{ + : id + : + $* <>EOO + : foo-bar + : + : foo bar + : bar baz + cmd + EOI + : id:foo-bar + : + : foo bar + : bar baz + cmd + EOO + + : summary + : + { + : only + : + $* <>EOO + : foo bar + : + : foo bar + : bar baz + cmd + EOI + : sm:foo bar + : + : foo bar + : bar baz + cmd + EOO + + : assumed + : + $* <>EOO + : foo bar + : bar baz + cmd + EOI + : foo bar + : bar baz + cmd + EOO + + : id + : + $* <>EOO + : foo-bar + : foo bar + : + : foo bar + : bar baz + cmd + EOI + : id:foo-bar + : sm:foo bar + : + : foo bar + : bar baz + cmd + EOO + + : id-assumed + : + $* <>EOO + : foo-bar + : bar baz + : baz fox + cmd + EOI + : foo-bar + : bar baz + : baz fox + cmd + EOO + } +} + +: legal : -: foo bar -: bar baz -cmd -EOI -: id:foo-bar +: Legal places for description. : -: foo bar -: bar baz -cmd -EOO +{ + : var + : + $* <>EOO + : foo bar + x = y; + cmd $x + EOI + : sm:foo bar + cmd y + EOO +} -$* <>EOO # summary-details -: foo bar +: illegal : -: foo bar -: bar baz -cmd -EOI -: sm:foo bar +: Illegal places for description. : -: foo bar -: bar baz -cmd -EOO +{ + : eof + : + $* <": foo" 2>>EOE != 0 + testscript:2:1: error: description before + EOE + + : rcbrace + : + $* <>EOE != 0 + { + cmd + : foo + } + EOI + testscript:4:1: error: description before '}' + EOE -$* <>EOO # id-summary-details -: foo-bar -: foo bar + : setup + : + $* <>EOE != 0 + : foo + +cmd + EOI + testscript:2:1: error: description before setup command + EOE + + : tdown + : + $* <>EOE != 0 + : foo + -cmd + EOI + testscript:2:1: error: description before teardown command + EOE + + : var + : + $* <>EOE != 0 + : foo + x = y + EOI + testscript:2:1: error: description before setup/teardown variable + EOE + + : var-if + : + $* <>EOE != 0 + : foo + if true + x = y + end + EOI + testscript:2:1: error: description before/after setup/teardown variable-if + EOE + + : var-if-after + : + $* <>EOE != 0 + if true + x = y + end : foo + EOI + testscript:1:1: error: description before/after setup/teardown variable-if + EOE + + : test + : + $* <>EOE != 0 + cmd1; + : foo + cmd2 + EOI + testscript:2:1: error: description inside test + EOE +} + +: test-scope : -: foo bar -: bar baz -cmd -EOI -: id:foo-bar -: sm:foo bar +: Interaction with test scope merging. : -: foo bar -: bar baz -cmd -EOO +{ + : both + : + : No merge since both have description. + : + $* -s -i <>EOO + : foo + { + : bar + cmd + } + EOI + { + : id:foo + { # foo + : id:bar + { # foo/bar + cmd + } + } + } + EOO + + : test + : + : No merge since test has description. + : + $* -s -i <>EOO + { + : foo-bar + : foo bar + cmd + } + EOI + { + { # 1 + : id:foo-bar + : sm:foo bar + { # 1/foo-bar + cmd + } + } + } + EOO -$* <>EOO # blanks + : group + : + $* -s -i <>EOO + : foo-bar + : foo bar + { + cmd + } + EOI + { + : id:foo-bar + : sm:foo bar + { # foo-bar + cmd + } + } + EOO +} + +: blanks +: +$* <>EOO : : : foo bar @@ -126,7 +426,9 @@ EOI cmd EOO -$* <>EOO # strip +: strip +: +$* <>EOO : foo-bar : bar baz : @@ -145,7 +447,9 @@ EOI cmd EOO -$* <>EOO # trail-compound +: trail-compound +: +$* <>EOO cmd1; cmd2: foo EOI @@ -154,7 +458,9 @@ cmd1 cmd2 EOO -$* <>EOE != 0 # empty +: empty +: +$* <>EOE != 0 : : cmd @@ -162,225 +468,19 @@ EOI testscript:1:1: error: empty description EOE -$* <>EOE != 0 # trail-empty +: trail-empty +: +$* <>EOE != 0 cmd: EOI testscript:1:4: error: empty description EOE -$* <>EOE != 0 # both +: both +: +$* <>EOE != 0 : foo cmd : bar EOI testscript:2:1: error: both leading and trailing descriptions EOE - -# Legal places for a description. -# -$* <>EOO # legal-var -: foo bar -x = y; -cmd $x -EOI -: sm:foo bar -cmd y -EOO - -# Illegal places for a description. -# -$* <": foo" 2>>EOE != 0 # illegal-eof -testscript:2:1: error: description before -EOE - -$* <>EOE != 0 # illegal-rcbrace -{ - cmd - : foo -} -EOI -testscript:4:1: error: description before '}' -EOE - -$* <>EOE != 0 # illegal-setup -: foo -+cmd -EOI -testscript:2:1: error: description before setup command -EOE - -$* <>EOE != 0 # illegal-tdown -: foo --cmd -EOI -testscript:2:1: error: description before teardown command -EOE - -$* <>EOE != 0 # illegal-var -: foo -x = y -EOI -testscript:2:1: error: description before setup/teardown variable -EOE - -$* <>EOE != 0 # illegal-var-if -: foo -if true - x = y -end -EOI -testscript:2:1: error: description before/after setup/teardown variable-if -EOE - -$* <>EOE != 0 # illegal-var-if-after -if true - x = y -end : foo -EOI -testscript:1:1: error: description before/after setup/teardown variable-if -EOE - -$* <>EOE != 0 # illegal-test -cmd1; -: foo -cmd2 -EOI -testscript:2:1: error: description inside test -EOE - -# Id uniqueness. -# -$* <>EOE != 0 # id-dup-test-test -: foo -cmd -: foo -cmd -EOI -testscript:3:1: error: duplicate id foo - testscript:1:1: info: previously used here -EOE - -$* <>EOE != 0 # id-dup-test-group -: foo -cmd -: foo -{ - cmd - cmd -} -EOI -testscript:3:1: error: duplicate id foo - testscript:1:1: info: previously used here -EOE - -$* <>EOE != 0 # id-dup-group-test -: foo -{ - cmd - cmd -} -: foo -cmd -EOI -testscript:6:1: error: duplicate id foo - testscript:1:1: info: previously used here -EOE - -$* <>EOE != 0 # id-dup-group-group -: foo -{ - cmd - cmd -} -: foo -{ - cmd - cmd -} -EOI -testscript:6:1: error: duplicate id foo - testscript:1:1: info: previously used here -EOE - -$* <>EOE != 0 # id-dup-group-derived -: 3 -cmd -{ - cmd - cmd -} -EOI -testscript:3:1: error: duplicate id 3 - testscript:1:1: info: previously used here -EOE - -$* <>EOE != 0 # id-dup-test-derived -: 3 -cmd -cmd -EOI -testscript:3:1: error: duplicate id 3 - testscript:1:1: info: previously used here -EOE - -# Interaction with test scope merging. -# - -: test-scope-both -: -: No merge since both have description. -: -$* -s -i <>EOO -: foo -{ - : bar - cmd -} -EOI -{ - : id:foo - { # foo - : id:bar - { # foo/bar - cmd - } - } -} -EOO - -: test-scope-test -: -: No merge since test has description. -: -$* -s -i <>EOO # -{ - : foo-bar - : foo bar - cmd -} -EOI -{ - { # 1 - : id:foo-bar - : sm:foo bar - { # 1/foo-bar - cmd - } - } -} -EOO - -$* -s -i <>EOO # test-scope-group -: foo-bar -: foo bar -{ - cmd -} -EOI -{ - : id:foo-bar - : sm:foo bar - { # foo-bar - cmd - } -} -EOO diff --git a/unit-tests/test/script/parser/directive.test b/unit-tests/test/script/parser/directive.test index 07cb65c..d426d9c 100644 --- a/unit-tests/test/script/parser/directive.test +++ b/unit-tests/test/script/parser/directive.test @@ -1,3 +1,7 @@ +# file : unit-tests/test/script/parser/directive.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + : not-directive : $* <>EOO diff --git a/unit-tests/test/script/parser/exit.test b/unit-tests/test/script/parser/exit.test index 263179b..9a4f9dc 100644 --- a/unit-tests/test/script/parser/exit.test +++ b/unit-tests/test/script/parser/exit.test @@ -1,3 +1,7 @@ +# file : unit-tests/test/script/parser/exit.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + : eq : $* <>EOO diff --git a/unit-tests/test/script/parser/expansion.test b/unit-tests/test/script/parser/expansion.test index 1d10a63..0a40827 100644 --- a/unit-tests/test/script/parser/expansion.test +++ b/unit-tests/test/script/parser/expansion.test @@ -1,8 +1,11 @@ -# Make sure everything expanded as strings. -# +# file : unit-tests/test/script/parser/expansion.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file -# quote -# +: quote +: +: Make sure everything expanded as strings. +: $* <>EOO x = dir/ proj% proj%name proj%proj%dir/type{name name {name}} cmd dir/ proj% proj%name proj%proj%dir/type{name name {name}} diff --git a/unit-tests/test/script/parser/here-document.test b/unit-tests/test/script/parser/here-document.test index 4afcf68..1e4f93b 100644 --- a/unit-tests/test/script/parser/here-document.test +++ b/unit-tests/test/script/parser/here-document.test @@ -1,3 +1,7 @@ +# file : unit-tests/test/script/parser/here-document.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + : end-marker : { diff --git a/unit-tests/test/script/parser/here-string.test b/unit-tests/test/script/parser/here-string.test index 9c4b68b..ab16779 100644 --- a/unit-tests/test/script/parser/here-string.test +++ b/unit-tests/test/script/parser/here-string.test @@ -1,10 +1,18 @@ -$* <>EOO # empty +# file : unit-tests/test/script/parser/here-string.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: empty +: +$* <>EOO cmd <"" EOI cmd <'' EOO -$* <>EOO # empty-nn +: empty-nn +: +$* <>EOO cmd <:"" EOI cmd <:'' diff --git a/unit-tests/test/script/parser/include.test b/unit-tests/test/script/parser/include.test index 7910919..c810036 100644 --- a/unit-tests/test/script/parser/include.test +++ b/unit-tests/test/script/parser/include.test @@ -1,3 +1,7 @@ +# file : unit-tests/test/script/parser/include.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + : none : $* <- != 0 +$* <>~/EOE/ != 0 .include foo.test EOI +/testscript:1:2: error: unable to read testscript foo.test: .+/ +EOE diff --git a/unit-tests/test/script/parser/pipe-expr.test b/unit-tests/test/script/parser/pipe-expr.test index 74077e7..cc0bd7e 100644 --- a/unit-tests/test/script/parser/pipe-expr.test +++ b/unit-tests/test/script/parser/pipe-expr.test @@ -1,3 +1,7 @@ +# file : unit-tests/test/script/parser/pipe-expr.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + : pipe : $* <>EOO diff --git a/unit-tests/test/script/parser/pre-parse.test b/unit-tests/test/script/parser/pre-parse.test index 4057f9a..d2ae7ce 100644 --- a/unit-tests/test/script/parser/pre-parse.test +++ b/unit-tests/test/script/parser/pre-parse.test @@ -1,15 +1,23 @@ -# attribute-pair -# -$* <>EOE != 0 -x = [foo=bar] -EOI -testscript:1:5: error: unknown value attribute foo=bar -EOE +# file : unit-tests/test/script/parser/pre-parse.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file -# attribute-pair-empty -# -$* <>EOE != 0 -x = [foo=] -EOI -testscript:1:5: error: unknown value attribute foo -EOE +: attribute +: +{ + : pair + : + $* <>EOE != 0 + x = [foo=bar] + EOI + testscript:1:5: error: unknown value attribute foo=bar + EOE + + : pair-empty + : + $* <>EOE != 0 + x = [foo=] + EOI + testscript:1:5: error: unknown value attribute foo + EOE +} diff --git a/unit-tests/test/script/parser/redirect.test b/unit-tests/test/script/parser/redirect.test index 2642834..5a91354 100644 --- a/unit-tests/test/script/parser/redirect.test +++ b/unit-tests/test/script/parser/redirect.test @@ -1,117 +1,185 @@ +# file : unit-tests/test/script/parser/redirect.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + # @@ Add tests for redirects other than file and merge. # @@ Does it make sense to split into separate files - one per redirect type? # -$* <>EOO # file -cmd 0<<>>b 2>>>&c -EOI -cmd <<>>b 2>>>&c -EOO - -$* <>EOO # quote-file -cmd 0<<<"a f" 1>>>"b f" 2>>>&"c f" -EOI -cmd <<<'a f' >>>'b f' 2>>>&'c f' -EOO - -$* <>EOE !=0 # in-file-fail1 -cmd <<< -EOI -testscript:1:8: error: missing stdin file -EOE - -$* <>EOE !=0 # in-file-fail2 -cmd <<<"" -EOI -testscript:1:8: error: empty stdin redirect path -EOE - -$* <>EOE !=0 # out-file-fail1 -cmd >>> -EOI -testscript:1:8: error: missing stdout file -EOE - -$* <>EOE !=0 # out-file-fail2 -cmd >>>"" -EOI -testscript:1:8: error: empty stdout redirect path -EOE - -$* <>EOE !=0 # err-file-fail1 -cmd 2>>> -EOI -testscript:1:9: error: missing stderr file -EOE - -$* <>EOE !=0 # err-file-fail2 -cmd 2>>>"" -EOI -testscript:1:9: error: empty stderr redirect path -EOE - -$* <>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: stdout merge redirect file descriptor must be 2 -EOE - -$* <>EOE != 0 # out-merge-fail2 -cmd 1>&1 -EOI -testscript:1:8: error: stdout merge redirect file descriptor 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: stderr merge redirect file descriptor must be 1 -EOE - -$* <>EOE != 0 # err-merge-fail2 -cmd 2>&2 -EOI -testscript:1:8: error: stderr merge redirect file descriptor 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 redirected to each other -EOE +: file +: +{ + : not-quote + : + $* <>EOO + cmd 0<<>>b 2>>>&c + EOI + cmd <<>>b 2>>>&c + EOO + + : quote + : + $* <>EOO + cmd 0<<<"a f" 1>>>"b f" 2>>>&"c f" + EOI + cmd <<<'a f' >>>'b f' 2>>>&'c f' + EOO + + : in + : + { + : missed + : + $* <>EOE !=0 + cmd <<< + EOI + testscript:1:8: error: missing stdin file + EOE + + : empty + : + $* <>EOE !=0 + cmd <<<"" + EOI + testscript:1:8: error: empty stdin redirect path + EOE + } + + : out + : + { + : missed + : + $* <>EOE !=0 + cmd >>> + EOI + testscript:1:8: error: missing stdout file + EOE + + : empty + : + $* <>EOE !=0 + cmd >>>"" + EOI + testscript:1:8: error: empty stdout redirect path + EOE + } + + : err + : + { + : missed + : + $* <>EOE !=0 + cmd 2>>> + EOI + testscript:1:9: error: missing stderr file + EOE + + : empty + : + $* <>EOE !=0 + cmd 2>>>"" + EOI + testscript:1:9: error: empty stderr redirect path + EOE + } +} + +: merge +{ + : out + : + { + : err + : + $* <>EOO + cmd 1>&2 + EOI + cmd >&2 + EOO + + : no-mutual + : + $* <>EOO + cmd 1>&2 2>&1 2>a + EOI + cmd >&2 2>a + EOO + + : not-descriptor + : + $* <>EOE != 0 + cmd 1>&a + EOI + testscript:1:8: error: stdout merge redirect file descriptor must be 2 + EOE + + : self + : + $* <>EOE != 0 + cmd 1>&1 + EOI + testscript:1:8: error: stdout merge redirect file descriptor must be 2 + EOE + + : missed + : + $* <>EOE != 0 + cmd 1>& + EOI + testscript:1:8: error: missing stdout file descriptor + EOE + } + + : err + { + : out + : + $* <>EOO + cmd 2>&1 + EOI + cmd 2>&1 + EOO + + : no-mutual + : + $* <>EOO + cmd 1>&2 2>&1 >a + EOI + cmd >a 2>&1 + EOO + + : not-descriptor + : + $* <>EOE != 0 + cmd 2>&a + EOI + testscript:1:8: error: stderr merge redirect file descriptor must be 1 + EOE + + : self + : + $* <>EOE != 0 + cmd 2>&2 + EOI + testscript:1:8: error: stderr merge redirect file descriptor must be 1 + EOE + + : missed + : + $* <>EOE != 0 + cmd 2>& + EOI + testscript:1:8: error: missing stderr file descriptor + EOE + } + + : mutual + : + $* <>EOE != 0 + cmd 1>&2 2>&1 + EOI + testscript:1:14: error: stdout and stderr redirected to each other + EOE +} diff --git a/unit-tests/test/script/parser/regex.test b/unit-tests/test/script/parser/regex.test index 9f2e737..f3fda75 100644 --- a/unit-tests/test/script/parser/regex.test +++ b/unit-tests/test/script/parser/regex.test @@ -8,7 +8,7 @@ : stdout : { - : missing + : missed : $* <'cmd >~' 2>>EOE != 0 testscript:1:7: error: missing stdout here-string regex @@ -67,7 +67,7 @@ : stderr : { - : missing + : missed : $* <'cmd 2>~' 2>>EOE != 0 testscript:1:8: error: missing stderr here-string regex @@ -97,7 +97,7 @@ : stdout : { - : missing + : missed : $* <'cmd >>~' 2>>EOE != 0 testscript:1:8: error: expected here-document regex end marker @@ -185,7 +185,7 @@ : stderr : { - : missing + : missed : $* <'cmd 2>>~' 2>>EOE != 0 testscript:1:9: error: expected here-document regex end marker diff --git a/unit-tests/test/script/parser/scope-if.test b/unit-tests/test/script/parser/scope-if.test index e04c47e..4f524cf 100644 --- a/unit-tests/test/script/parser/scope-if.test +++ b/unit-tests/test/script/parser/scope-if.test @@ -1,365 +1,450 @@ -: if-true +# file : unit-tests/test/script/parser/scope-if.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: if : -$* -s <>EOO -if true foo -{ - cmd -} -EOI { - ? true foo + : true + : + $* -s <>EOO + if true foo { cmd } -} -EOO + EOI + { + ? true foo + { + cmd + } + } + EOO -: if-false -: -$* -s <>EOO -if false foo -{ - cmd -} -EOI -{ - ? false foo -} -EOO + : false + : + $* -s <>EOO + if false foo + { + cmd + } + EOI + { + ? false foo + } + EOO -: ifn-true -: -$* -s <>EOO -if! true -{ - cmd -} -EOI -{ - ? true -} -EOO + : not-true + : + $* -s <>EOO + if! true + { + cmd + } + EOI + { + ? true + } + EOO -: ifn-false -: -$* -s <>EOO -if! false -{ - cmd -} -EOI -{ - ? false + : not-false + : + $* -s <>EOO + if! false { cmd } + EOI + { + ? false + { + cmd + } + } + EOO + + : eos-inside + : + $* <>EOE != 0 + if + { + EOI + testscript:3:1: error: expected '}' at the end of the scope + EOE + } -EOO -: elif-true +: elif : -$* -s <>EOO -if false -{ - cmd -} -elif true { - cmd1 -} -EOI -{ - ? false - ? true + : true + : + $* -s <>EOO + if false + { + cmd + } + elif true { cmd1 } -} -EOO + EOI + { + ? false + ? true + { + cmd1 + } + } + EOO -: elif-false -: -$* -s <>EOO -if false -{ - cmd -} -elif false -{ - cmd -} -EOI -{ - ? false - ? false -} -EOO + : false + : + $* -s <>EOO + if false + { + cmd + } + elif false + { + cmd + } + EOI + { + ? false + ? false + } + EOO -: elifn-false -: -$* -s <>EOO -if false -{ - cmd -} -elif! false -{ - cmd1 -} -EOI -{ - ? false - ? false + : not-false + : + $* -s <>EOO + if false + { + cmd + } + elif! false { cmd1 } -} -EOO + EOI + { + ? false + ? false + { + cmd1 + } + } + EOO -: elifn-true -: -$* -s <>EOO -if false -{ - cmd -} -elif! true -{ - cmd -} -EOI -{ - ? false - ? true -} -EOO + : not-true + : + $* -s <>EOO + if false + { + cmd + } + elif! true + { + cmd + } + EOI + { + ? false + ? true + } + EOO -: else-true -: -$* -s <>EOO -if false -{ - cmd -} -else -{ - cmd1 -} -EOI -{ - ? false + : after-else + : + $* <>EOE != 0 + if false { - cmd1 + cmd + } + else + { + cmd + } + elif true + { + cmd } + EOI + testscript:9:1: error: 'elif' after 'else' + EOE } -EOO -: else-false +: else : -$* -s <>EOO -if true -{ - cmd1 -} -else { - cmd -} -EOI -{ - ? true + : true + : + $* -s <>EOO + if false + { + cmd + } + else { cmd1 } -} -EOO - -: if-chain -: -$* -s <>EOO -if false -{ - cmd -} -elif false -{ - cmd - cmd -} -elif false -{ - cmd -} -elif true -{ - cmd1 - cmd2 -} -elif false -{ - cmd -} -else -{ - cmd - cmd -} -EOI -{ - ? false - ? false - ? false - ? true + EOI { + ? false { cmd1 } + } + EOO + + : false + : + $* -s <>EOO + if true + { + cmd1 + } + else + { + cmd + } + EOI + { + ? true { - cmd2 + cmd1 } } -} -EOO + EOO -: nested-take -: -$* -s <>EOO -if true -{ - cmd1 + : chain + : + $* -s <>EOO if false { cmd } elif false { - if true - { - cmd - } + cmd + cmd } - else + elif false + { + cmd + } + elif true { + cmd1 cmd2 } - cmd3 -} -EOI -{ - ? true + elif false { - { - cmd1 - } + cmd + } + else + { + cmd + cmd + } + EOI + { + ? false ? false ? false + ? true { { + cmd1 + } + { cmd2 } } - { - cmd3 - } } -} -EOO + EOO -: nested-skip -: -$* -s <>EOO -if false -{ - cmd1 + : scope-expected + : + $* <>EOE != 0 + if + { + cmd + } + else + cmd + EOI + testscript:5:1: error: expected scope after 'else' + EOE + + : after-else + : + $* <>EOE != 0 if false { cmd } - elif false + else { - if true - { - cmd - } + cmd } else { - cmd2 + cmd } - cmd3 + EOI + testscript:9:1: error: 'else' after 'else' + EOE } -else -{ - cmd -} -EOI + +: nested +: { - ? false + : take + : + $* -s <>EOO + if true { + cmd1 + if false { cmd } + elif false + { + if true + { + cmd + } + } + else + { + cmd2 + } + cmd3 } -} -EOO + EOI + { + ? true + { + { + cmd1 + } + ? false + ? false + { + { + cmd2 + } + } + { + cmd3 + } + } + } + EOO -: demote-group -: Chain remains a group -: -$* -s <>EOO -if false -{ - cmd -} -elif true -{ - cmd1 - cmd2 -} -else -{ - cmd -} -EOI -{ - ? false - ? true + : skip + : + $* -s <>EOO + if false { + cmd1 + if false { - cmd1 + cmd } + elif false + { + if true + { + cmd + } + } + else { cmd2 } + cmd3 + } + else + { + cmd + } + EOI + { + ? false + { + { + cmd + } + } } + EOO } -EOO -: demote-test -: Chain demoted to test +: demote : -$* -s <>EOO -if false { - cmd -} -elif true -{ - cmd1 -} -else -{ - cmd -} -EOI -{ - ? false - ? true + : group + : Chain remains a group + : + $* -s <>EOO + if false + { + cmd + } + elif true + { + cmd1 + cmd2 + } + else + { + cmd + } + EOI + { + ? false + ? true + { + { + cmd1 + } + { + cmd2 + } + } + } + EOO + + : test + : Chain demoted to test + : + $* -s <>EOO + if false + { + cmd + } + elif true { cmd1 } + else + { + cmd + } + EOI + { + ? false + ? true + { + cmd1 + } + } + EOO } -EOO : line-index : Make sure command line index spans setup/if/teardown @@ -467,63 +552,3 @@ EOI } } EOO - -: eos-inside -: -$* <>EOE != 0 -if -{ -EOI -testscript:3:1: error: expected '}' at the end of the scope -EOE - -: scope-expected -: -$* <>EOE != 0 -if -{ - cmd -} -else -cmd -EOI -testscript:5:1: error: expected scope after 'else' -EOE - -: else-after-else -: -$* <>EOE != 0 -if false -{ - cmd -} -else -{ - cmd -} -else -{ - cmd -} -EOI -testscript:9:1: error: 'else' after 'else' -EOE - -: elif-after-else -: -$* <>EOE != 0 -if false -{ - cmd -} -else -{ - cmd -} -elif true -{ - cmd -} -EOI -testscript:9:1: error: 'elif' after 'else' -EOE diff --git a/unit-tests/test/script/parser/scope.test b/unit-tests/test/script/parser/scope.test index 7d78aca..144dc54 100644 --- a/unit-tests/test/script/parser/scope.test +++ b/unit-tests/test/script/parser/scope.test @@ -1,5 +1,9 @@ -$* testscript <'cmd $@' >"cmd 1" # id-testscript -$* foo.test <'cmd $@' >"cmd foo/1" # id +# file : unit-tests/test/script/parser/scope.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +$* testscript <'cmd $@' >"cmd 1" : id-testscript +$* foo.test <'cmd $@' >"cmd foo/1" : id : wd-testscript : @@ -9,214 +13,268 @@ $* testscript <'cmd "$~"' >~"%cmd '?.+[/\\\\]test-driver[/\\\\]1'?%" : $* foo.test <'cmd "$~"' >~"%cmd '?.+[/\\\\]test-driver[/\\\\]foo[/\\\\]1'?%" -$* -s <>EOO # group -{ - cmd1 - cmd2 -} -EOI -{ + : empty-empty + : + $* -s <>EOO # test-scope -{ - cmd -} -EOI -{ - { # 1 - cmd - } -} -EOO - -$* -s -i <>EOO # test-scope-nested -{ + : non-empty + : + $* -s <>EOO { - cmd + cmd1 + cmd2 } -} -EOI -{ - { # 1 - cmd + EOI + { + { + { + cmd1 + } + { + cmd2 + } + } } + EOO } -EOO -$* -s -i <>EOO # test-scope-var -{ - x = abc - cmd $x -} -EOI +: test +: { - { # 1 - cmd abc - } -} -EOO + : explicit + : + { + : one-level + : + $* -s -i <>EOO + { + cmd + } + EOI + { + { # 1 + cmd + } + } + EOO -$* -s -i <>EOO # test-scope-setup -{ - x = abc - +setup - cmd $x -} -EOI -{ - { # 1 - setup - { # 1/4 - cmd abc + : nested + : + $* -s -i <>EOO + { + { + cmd + } } + EOI + { + { # 1 + cmd + } + } + EOO + + : var + : + $* -s -i <>EOO + { + x = abc + cmd $x + } + EOI + { + { # 1 + cmd abc + } + } + EOO + + : setup + : + $* -s -i <>EOO + { + x = abc + +setup + cmd $x + } + EOI + { + { # 1 + setup + { # 1/4 + cmd abc + } + } + } + EOO } -} -EOO + : implicit + { + : one-cmd + : + $* -s <>EOO + cmd1 + EOI + { + { + cmd1 + } + } + EOO -# -# -$* <:"{x" 2>>EOE != 0 # expected-newline-lcbrace -testscript:1:2: error: expected newline after '{' -EOE + : two-cmd + : + $* -s <>EOO + cmd1; + cmd2 + EOI + { + { + cmd1 + cmd2 + } + } + EOO -$* <"{" 2>>EOE != 0 # expected-rcbrace -testscript:2:1: error: expected '}' at the end of the scope -EOE + : three-cmd + : + $* -s <>EOO + cmd1; + cmd2; + cmd3 + EOI + { + { + cmd1 + cmd2 + cmd3 + } + } + EOO -$* <>EOE != 0 # expected-line-rcbrace -{ - cmd; -} -EOI -testscript:3:1: error: expected another line after ';' -EOE + : var + : + $* -s <>EOO + cmd1; + x = abc; + cmd2 $x + EOI + { + { + cmd1 + cmd2 abc + } + } + EOO -$* <<:EOI 2>>EOE != 0 # expected-newline-rcbrace -{ -} -EOI -testscript:2:2: error: expected newline after '}' -EOE + : var-first + : + $* -s <>EOO + x = abc; + cmd $x + EOI + { + { + cmd abc + } + } + EOO -$* -s <>EOO # test-1 -cmd1 -EOI -{ - { - cmd1 - } -} -EOO + : var-setup-tdown + : + $* -s <>EOO + x = abc + cmd $x + y = 123 + EOI + { + { + cmd abc + } + } + EOO -$* -s <>EOO # test-2 -cmd1; -cmd2 -EOI -{ - { + : after-tdown + : + $* <>EOE != 0 cmd1 + x = abc cmd2 + EOI + testscript:3:1: error: test after teardown + testscript:2:1: info: last teardown line appears here + EOE } } -EOO -$* -s <>EOO # test-3 -cmd1; -cmd2; -cmd3 -EOI +: expected { - { - cmd1 - cmd2 - cmd3 - } -} -EOO + : newline-lcbrace + : + $* <:"{x" 2>>EOE != 0 + testscript:1:2: error: expected newline after '{' + EOE -$* -s <>EOO # test-var -cmd1; -x = abc; -cmd2 $x -EOI -{ - { - cmd1 - cmd2 abc - } -} -EOO + : rcbrace + : + $* <"{" 2>>EOE != 0 + testscript:2:1: error: expected '}' at the end of the scope + EOE -$* -s <>EOO # test-var-first -x = abc; -cmd $x -EOI -{ + : line-rcbrace + : + $* <>EOE != 0 { - cmd abc + cmd; } -} -EOO + EOI + testscript:3:1: error: expected another line after ';' + EOE -$* -s <>EOO # var-setup-tdown -x = abc -cmd $x -y = 123 -EOI -{ + : newline-rcbrace + : + $* <<:EOI 2>>EOE != 0 { - cmd abc } + EOI + testscript:2:2: error: expected newline after '}' + EOE + + : line-eof + : + $* <>EOE != 0 + cmd; + EOI + testscript:2:1: error: expected another line after ';' + EOE + + : newline-cmd + : + $* <<:EOI 2>>EOE != 0 + cmd; + EOI + testscript:1:5: error: expected newline instead of + EOE + + : newline-var + : + $* <:"x = abc;" 2>>EOE != 0 + testscript:1:9: error: expected newline instead of + EOE } -EOO - -$* <>EOE != 0 # test-after-tdown -cmd1 -x = abc -cmd2 -EOI -testscript:3:1: error: test after teardown - testscript:2:1: info: last teardown line appears here -EOE - -$* <>EOE != 0 # expected-line-eof -cmd; -EOI -testscript:2:1: error: expected another line after ';' -EOE - -$* <<:EOI 2>>EOE != 0 # expected-newline-cmd -cmd; -EOI -testscript:1:5: error: expected newline instead of -EOE - -$* <:"x = abc;" 2>>EOE != 0 # expected-newline-var -testscript:1:9: error: expected newline instead of -EOE diff --git a/unit-tests/test/script/parser/setup-teardown.test b/unit-tests/test/script/parser/setup-teardown.test index 5d30ed4..c9183ef 100644 --- a/unit-tests/test/script/parser/setup-teardown.test +++ b/unit-tests/test/script/parser/setup-teardown.test @@ -1,43 +1,83 @@ -$* <"+cmd;" 2>>EOE != 0 # semi-after-setup -testscript:1:5: error: ';' after setup command -EOE - -$* <"+cmd:" 2>>EOE != 0 # colon-after-setup -testscript:1:5: error: ':' after setup command -EOE - -$* <"-cmd;" 2>>EOE != 0 # semi-after-tdown -testscript:1:5: error: ';' after teardown command -EOE - -$* <"-cmd:" 2>>EOE != 0 # colon-after-tdown -testscript:1:5: error: ':' after teardown command -EOE - -$* <>EOE != 0 # setup-in-test -cmd; -+cmd -EOI -testscript:2:1: error: setup command in test -EOE - -$* <>EOE != 0 # tdown-in-test -cmd; --cmd -EOI -testscript:2:1: error: teardown command in test -EOE - -$* <>EOE != 0 # setup-after-test -cmd -+cmd -EOI -testscript:2:1: error: setup command after tests -EOE - -$* <>EOE != 0 # setup-after-tdownt --cmd -+cmd -EOI -testscript:2:1: error: setup command after teardown -EOE +# file : unit-tests/test/script/parser/setup-teardown.test +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: setup +: +{ + : followed + : + { + : semi + : + $* <"+cmd;" 2>>EOE != 0 + testscript:1:5: error: ';' after setup command + EOE + + : colon + : + $* <"+cmd:" 2>>EOE != 0 + testscript:1:5: error: ':' after setup command + EOE + } + + : after + : + { + : test + : + $* <>EOE != 0 + cmd + +cmd + EOI + testscript:2:1: error: setup command after tests + EOE + + : after-tdownt + : + $* <>EOE != 0 + -cmd + +cmd + EOI + testscript:2:1: error: setup command after teardown + EOE + } + + : in-test + : + $* <>EOE != 0 + cmd; + +cmd + EOI + testscript:2:1: error: setup command in test + EOE +} + +: tdown +: +{ + : followed + : + { + : semi + : + $* <"-cmd;" 2>>EOE != 0 + testscript:1:5: error: ';' after teardown command + EOE + + : colon + : + $* <"-cmd:" 2>>EOE != 0 + testscript:1:5: error: ':' after teardown command + EOE + } + + : in-test + : + $* <>EOE != 0 + cmd; + -cmd + EOI + testscript:2:1: error: teardown command in test + EOE +} -- cgit v1.1