From 5007870b52aa549971824959a55ad3bb886f09e0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 3 Sep 2018 16:37:32 +0200 Subject: Rename .test/test{} to .testscript/testscript{} --- tests/name/buildfile | 2 +- tests/name/cross.test | 115 -------------- tests/name/cross.testscript | 115 ++++++++++++++ tests/name/extension.test | 86 ----------- tests/name/extension.testscript | 86 +++++++++++ tests/name/pattern.test | 332 ---------------------------------------- tests/name/pattern.testscript | 332 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 534 insertions(+), 534 deletions(-) delete mode 100644 tests/name/cross.test create mode 100644 tests/name/cross.testscript delete mode 100644 tests/name/extension.test create mode 100644 tests/name/extension.testscript delete mode 100644 tests/name/pattern.test create mode 100644 tests/name/pattern.testscript (limited to 'tests/name') diff --git a/tests/name/buildfile b/tests/name/buildfile index 4449a1f..1253202 100644 --- a/tests/name/buildfile +++ b/tests/name/buildfile @@ -2,4 +2,4 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -./: test{*} $b +./: testscript{*} $b diff --git a/tests/name/cross.test b/tests/name/cross.test deleted file mode 100644 index 009b851..0000000 --- a/tests/name/cross.test +++ /dev/null @@ -1,115 +0,0 @@ -# file : tests/name/cross.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -+cat <=build/root.build -define foo: file -define bar: file - -foo{*}: extension = foo -bar{*}: extension = bar -EOI - -: separation -: -{ - $* <'print fox/ {bar baz}' >'fox/ bar baz' : dir - $* <'print foo {bar baz}' >'foo bar baz' : type - $* <'print fox/foo {bar baz}' >'fox/foo bar baz' : dir-type -} - -: type -: -{ - $* <'print {}{bar}' >'bar' - $* <'print {foo}{}' >'foo{}' - $* <'print {foo}{bar}' >'foo{bar}' - $* <'print {foo}{bar baz}' >'foo{bar} foo{baz}' - $* <'print {foo fox}{bar}' >'foo{bar} fox{bar}' - $* <'print {foo fox}{bar baz}' >'foo{bar} foo{baz} fox{bar} fox{baz}' -} - -: dir -: -{ - $* <'print dir/{}{bar}' >'dir/bar' - $* <'print dir/{foo}{}' >'foo{dir/}' - $* <'print dir/{foo}{bar}' >'dir/foo{bar}' - $* <'print dir/{foo}{bar baz}' >'dir/foo{bar} dir/foo{baz}' - $* <'print dir/{foo fox}{bar}' >'dir/foo{bar} dir/fox{bar}' - $* <'print dir/{foo fox}{bar baz}' >'dir/foo{bar} dir/foo{baz} dir/fox{bar} dir/fox{baz}' - - $* <'print {dir/}{bar}' >'dir/bar' - $* <'print {dir/}{bar baz}' >'dir/bar dir/baz' - $* <'print {dir/ dor/}{bar}' >'dir/bar dor/bar' - $* <'print {dir/ dor/}{bar baz}' >'dir/bar dir/baz dor/bar dor/baz' -} - -: dir-type -: -{ - $* <'print {dir/foo}{bar}' >'dir/foo{bar}' - $* <'print {dir/foo}{bar baz}' >'dir/foo{bar} dir/foo{baz}' - $* <'print {dir/foo dor/fox}{bar}' >'dir/foo{bar} dor/fox{bar}' - $* <'print {dir/foo dor/fox}{bar baz}' >'dir/foo{bar} dir/foo{baz} dor/fox{bar} dor/fox{baz}' - - $* <'print {dir/}{foo}{bar}' >'dir/foo{bar}' - $* <'print {dir/}{foo}{bar baz}' >'dir/foo{bar} dir/foo{baz}' - $* <'print {dir/ dor/}{foo}{bar}' >'dir/foo{bar} dor/foo{bar}' - $* <'print {dir/ dor/}{foo fox}{bar baz}' >'dir/foo{bar} dir/foo{baz} dir/fox{bar} dir/fox{baz} dor/foo{bar} dor/foo{baz} dor/fox{bar} dor/fox{baz}' -} - -: proj -: -{ - $* <'print {prj%foo}{bar baz}' >'prj%foo{bar} prj%foo{baz}' - $* <'print {foo}{bar prj%baz}' >'foo{bar} prj%foo{baz}' - - $* <'print {prj%foo}{bar prk%baz}' 2>>EOE != 0 - :1:21: error: nested project name prk - EOE -} - -: merge -: -{ - $* <'print {foo}{bar dir/{baz}}' >'foo{bar} dir/foo{baz}' - $* <'print dir/{foo}{bar dor/{baz}}' >'dir/foo{bar} dir/dor/foo{baz}' - - $* <'print {dir/foo{}}{bar}' >'dir/foo{bar}' - $* <'print {dir/{foo}}{bar}' >'dir/foo{bar}' - $* <'print {dir/}{foo{bar}}' >'dir/foo{bar}' - - $* <'print {dir/foo{fox}}{bar}' 2>>EOE != 0 - :1:22: error: nested type name fox - EOE - - $* <'print {dir/foo}{fox{bar}}' 2>>EOE != 0 - :1:20: error: nested type name fox - EOE -} - -: pair -: -{ - $* <'print x@{dir/ dor/}{foo fox}{bar baz}' >'x@dir/foo{bar} x@dir/foo{baz} x@dir/fox{bar} x@dir/fox{baz} x@dor/foo{bar} x@dor/foo{baz} x@dor/fox{bar} x@dor/fox{baz}' -} - -: pattern -: -{ - touch x.foo y.bar; - $* <'print {foo bar}{*}' >'foo{x} bar{y}' - - mkdir dir && touch dir/x.foo; - $* <'print {*/}{*.foo}' >/'dir/x.foo' - - mkdir dir && touch dir/x.foo; - $* <'print {*/}{foo}{*}' >/'dir/foo{x}' -} - -# @@ TODO: nested replay. -# -#file{foo} file{bar}: x = {foo fox}{bar baz} diff --git a/tests/name/cross.testscript b/tests/name/cross.testscript new file mode 100644 index 0000000..d625a2c --- /dev/null +++ b/tests/name/cross.testscript @@ -0,0 +1,115 @@ +# file : tests/name/cross.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + ++cat <=build/root.build +define foo: file +define bar: file + +foo{*}: extension = foo +bar{*}: extension = bar +EOI + +: separation +: +{ + $* <'print fox/ {bar baz}' >'fox/ bar baz' : dir + $* <'print foo {bar baz}' >'foo bar baz' : type + $* <'print fox/foo {bar baz}' >'fox/foo bar baz' : dir-type +} + +: type +: +{ + $* <'print {}{bar}' >'bar' + $* <'print {foo}{}' >'foo{}' + $* <'print {foo}{bar}' >'foo{bar}' + $* <'print {foo}{bar baz}' >'foo{bar} foo{baz}' + $* <'print {foo fox}{bar}' >'foo{bar} fox{bar}' + $* <'print {foo fox}{bar baz}' >'foo{bar} foo{baz} fox{bar} fox{baz}' +} + +: dir +: +{ + $* <'print dir/{}{bar}' >'dir/bar' + $* <'print dir/{foo}{}' >'foo{dir/}' + $* <'print dir/{foo}{bar}' >'dir/foo{bar}' + $* <'print dir/{foo}{bar baz}' >'dir/foo{bar} dir/foo{baz}' + $* <'print dir/{foo fox}{bar}' >'dir/foo{bar} dir/fox{bar}' + $* <'print dir/{foo fox}{bar baz}' >'dir/foo{bar} dir/foo{baz} dir/fox{bar} dir/fox{baz}' + + $* <'print {dir/}{bar}' >'dir/bar' + $* <'print {dir/}{bar baz}' >'dir/bar dir/baz' + $* <'print {dir/ dor/}{bar}' >'dir/bar dor/bar' + $* <'print {dir/ dor/}{bar baz}' >'dir/bar dir/baz dor/bar dor/baz' +} + +: dir-type +: +{ + $* <'print {dir/foo}{bar}' >'dir/foo{bar}' + $* <'print {dir/foo}{bar baz}' >'dir/foo{bar} dir/foo{baz}' + $* <'print {dir/foo dor/fox}{bar}' >'dir/foo{bar} dor/fox{bar}' + $* <'print {dir/foo dor/fox}{bar baz}' >'dir/foo{bar} dir/foo{baz} dor/fox{bar} dor/fox{baz}' + + $* <'print {dir/}{foo}{bar}' >'dir/foo{bar}' + $* <'print {dir/}{foo}{bar baz}' >'dir/foo{bar} dir/foo{baz}' + $* <'print {dir/ dor/}{foo}{bar}' >'dir/foo{bar} dor/foo{bar}' + $* <'print {dir/ dor/}{foo fox}{bar baz}' >'dir/foo{bar} dir/foo{baz} dir/fox{bar} dir/fox{baz} dor/foo{bar} dor/foo{baz} dor/fox{bar} dor/fox{baz}' +} + +: proj +: +{ + $* <'print {prj%foo}{bar baz}' >'prj%foo{bar} prj%foo{baz}' + $* <'print {foo}{bar prj%baz}' >'foo{bar} prj%foo{baz}' + + $* <'print {prj%foo}{bar prk%baz}' 2>>EOE != 0 + :1:21: error: nested project name prk + EOE +} + +: merge +: +{ + $* <'print {foo}{bar dir/{baz}}' >'foo{bar} dir/foo{baz}' + $* <'print dir/{foo}{bar dor/{baz}}' >'dir/foo{bar} dir/dor/foo{baz}' + + $* <'print {dir/foo{}}{bar}' >'dir/foo{bar}' + $* <'print {dir/{foo}}{bar}' >'dir/foo{bar}' + $* <'print {dir/}{foo{bar}}' >'dir/foo{bar}' + + $* <'print {dir/foo{fox}}{bar}' 2>>EOE != 0 + :1:22: error: nested type name fox + EOE + + $* <'print {dir/foo}{fox{bar}}' 2>>EOE != 0 + :1:20: error: nested type name fox + EOE +} + +: pair +: +{ + $* <'print x@{dir/ dor/}{foo fox}{bar baz}' >'x@dir/foo{bar} x@dir/foo{baz} x@dir/fox{bar} x@dir/fox{baz} x@dor/foo{bar} x@dor/foo{baz} x@dor/fox{bar} x@dor/fox{baz}' +} + +: pattern +: +{ + touch x.foo y.bar; + $* <'print {foo bar}{*}' >'foo{x} bar{y}' + + mkdir dir && touch dir/x.foo; + $* <'print {*/}{*.foo}' >/'dir/x.foo' + + mkdir dir && touch dir/x.foo; + $* <'print {*/}{foo}{*}' >/'dir/foo{x}' +} + +# @@ TODO: nested replay. +# +#file{foo} file{bar}: x = {foo fox}{bar baz} diff --git a/tests/name/extension.test b/tests/name/extension.test deleted file mode 100644 index 160c427..0000000 --- a/tests/name/extension.test +++ /dev/null @@ -1,86 +0,0 @@ -# file : tests/name/extension.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -+cat <=build/root.build -define txt: file -txt{*}: extension = txt -EOI - -: name -: -{ - test.arguments = --match-only update - - : unspecified - : - touch foo.txt; - $* <'./: txt{foo}' - - : specified - : - touch foo.text; - $* <'./: txt{foo.text}' - - : specified-none - : - touch foo; - $* <'./: txt{foo.}' - - : specified-default - : - touch foo.test.txt; - $* <'./: txt{foo.test...}' - - # Trailing dots are not allowed on Windows. - # - - : specified-escape-one - : - if ($cxx.target.class != 'windows') - { - touch foo.; - $* <'./: txt{foo..}' - } - - : specified-escape-two - : - if ($cxx.target.class != 'windows') - { - touch foo..; - $* <'./: txt{foo....}' - } - - : specified-invalid - : - $* <'./: txt{foo.....}' 2>>EOE != 0 - :1:5: error: invalid trailing dot sequence in target name 'foo.....' - EOE -} - -: pattern -: -{ - : specified-none - : - touch foo; - $* <'print txt{fo?.}' >'txt{foo.}' - - : specified-default - : - touch foo.test.txt; - $* <'print txt{fo?.test...}' >'txt{foo.test...}' - - # Trailing dots are not allowed on Windows. - # - - : specified-escape - : - if ($cxx.target.class != 'windows') - { - touch foo.; - $* <'print txt{fo?..}' >'txt{foo..}' - } -} diff --git a/tests/name/extension.testscript b/tests/name/extension.testscript new file mode 100644 index 0000000..f9df173 --- /dev/null +++ b/tests/name/extension.testscript @@ -0,0 +1,86 @@ +# file : tests/name/extension.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + ++cat <=build/root.build +define txt: file +txt{*}: extension = txt +EOI + +: name +: +{ + test.arguments = --match-only update + + : unspecified + : + touch foo.txt; + $* <'./: txt{foo}' + + : specified + : + touch foo.text; + $* <'./: txt{foo.text}' + + : specified-none + : + touch foo; + $* <'./: txt{foo.}' + + : specified-default + : + touch foo.testscript.txt; + $* <'./: txt{foo.testscript...}' + + # Trailing dots are not allowed on Windows. + # + + : specified-escape-one + : + if ($cxx.target.class != 'windows') + { + touch foo.; + $* <'./: txt{foo..}' + } + + : specified-escape-two + : + if ($cxx.target.class != 'windows') + { + touch foo..; + $* <'./: txt{foo....}' + } + + : specified-invalid + : + $* <'./: txt{foo.....}' 2>>EOE != 0 + :1:5: error: invalid trailing dot sequence in target name 'foo.....' + EOE +} + +: pattern +: +{ + : specified-none + : + touch foo; + $* <'print txt{fo?.}' >'txt{foo.}' + + : specified-default + : + touch foo.testscript.txt; + $* <'print txt{fo?.testscript...}' >'txt{foo.testscript...}' + + # Trailing dots are not allowed on Windows. + # + + : specified-escape + : + if ($cxx.target.class != 'windows') + { + touch foo.; + $* <'print txt{fo?..}' >'txt{foo..}' + } +} diff --git a/tests/name/pattern.test b/tests/name/pattern.test deleted file mode 100644 index 8d8840c..0000000 --- a/tests/name/pattern.test +++ /dev/null @@ -1,332 +0,0 @@ -# file : tests/name/pattern.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -+cat <=build/root.build -define txt: file -txt{*}: extension = txt -EOI - -$* <'print pp%*.txt' >'pp%*.txt' : project-simple -$* <'print pp%{*.txt -x*}' >'pp%*.txt pp%-x*' : project-group - -$* <"print '*.txt'" >'*.txt' : quoted-single -$* <'print "*.txt"' >'*.txt' : quoted-double -$* <'*.txt' : quoted-expansion -pat = '*' -print "$(pat).txt" -EOI - -: detect -: -: Test pattern_mode parsing logic. -{ - : second-pattern - : - touch foo.txt; - $* <'print {foo *.txt}' >'foo foo.txt' - - : independent-patterns - : - touch foo.txt -bar; - $* <'print {*.txt foo* -b*}' >'foo.txt foo.txt -bar' - - : second-inclusion - : - touch foo.txt bar.txt; - $* <'print {f*.txt +b*.txt}' >'foo.txt bar.txt' -} - -: diagnostics -: -{ - : simple - : - $* <'print {*.txt +foo file{bar}}' 2>>EOE != 0 - :1:19: error: name pattern inclusion or exclusion expected - EOE - - : inclusion-exclusion-sign - : - $* <'print {*.txt -foo bar}' 2>>EOE != 0 - :1:19: error: name pattern inclusion or exclusion expected - EOE - - : inclusion-quoted - : - $* <'print {*.txt -foo "+bar"}' 2>>EOE != 0 - :1:19: error: name pattern inclusion or exclusion expected - EOE - - : empty-inclusion-exclusion - : - $* <'print {*.txt -}' 2>>EOE != 0 - :1:8: error: empty name pattern - EOE - - : inconsistent-result - : - $* <'print {*.txt +foo/}' 2>>EOE != 0 - :1:8: error: inconsistent file/directory result in name pattern - EOE -} - -: basics -: -{ - touch foo.txt; - $* <'print *.txt' >'foo.txt' : simple-file - - mkdir foo; - $* <'print */' >/'foo/' : simple-dir - - touch foo.txt; - $* <'print {*.txt}' >'foo.txt' : group - - touch foo.txt; - $* <'print {+*.txt}' >'foo.txt' : plus-prefixed - - mkdir dir && touch dir/foo.txt; - $* <'print dir/{*.txt}' >'dir/foo.txt' : dir - - touch foo.txt; - $* <'print file{*.txt}' >'file{foo.txt}' : type - - touch foo.txt; - $* <'print x@{*.txt}' >'x@foo.txt' : pair - - touch bar.txt; - $* <'print x@dir/file{f*.txt}' >'' : empty - - mkdir dir && touch dir/foo.txt; - $* <'print **.txt' >/'dir/foo.txt' : recursive - - mkdir dir && touch dir/foo.txt; - $* <'print d*/*.txt' >/'dir/foo.txt' : multi-pattern - - touch foo.txt bar.txt; - $* <'print {*.txt -bar.txt}' >'foo.txt' : exclude-non-pattern - - mkdir baz; - touch foo.txt bar.txt baz/fox.txt baz/box.txt; - $* <'print {**.txt -b*.txt -b*/*}' >'foo.txt' : exclude-pattern - - touch foo.txt bar.txt baz.txt; - $* <'print {*.txt -{*z.txt bar.txt}}' >'foo.txt' : exclude-group - - touch bar.txt; - $* <'print {f*.txt +bar.txt}' >'bar.txt' : include-non-wildcard - - touch bar.txt; - $* <'print {f*.txt +b*.txt}' >'bar.txt' : include-pattern - - mkdir bar; - $* <'print {f*/ +{b*/}}' >/'bar/' : include-group - - touch foo.txt fox.txt; - $* <'print {*.txt -f*.txt +*x.txt}' >'fox.txt' : include-exclude-order - - touch foo.txt; - $* <'print {+foo.txt} {+bar.txt}' >'foo.txt' : non-wildcard -} - -: target-type -: -: Test target type-specific pattern amendment logic. -{ - : append-extension - : - touch foo.txt bar.txt; - $* <'print txt{* -bar}' >'txt{foo}' - - : existing-extension - : - touch foo.txt bar.txt; - $* <'print txt{*.txt -bar.txt}' >'txt{foo.txt}' - - : append-slash - : - mkdir foo bar; - $* <'print dir{* -bar}' >/'dir{foo/}' - - : existing-slash - : - mkdir foo bar; - $* <'print dir{*/ -bar/}' >/'dir{foo/}' -} - -: dot -: -: Test filtering of hidden files/directories. -{ - touch foo.txt .foo.txt; - $* <'print *.txt' >'foo.txt' : file-excl - - touch foo.txt .foo.txt; - $* <'print .*.txt' >'.foo.txt' : file-incl - - mkdir dir .dir; - $* <'print */' >/'dir/' : dir-excl - - mkdir dir .dir; - $* <'print .*/' >/'.dir/' : dir-incl - - mkdir dir .dir && touch dir/foo.txt .dir/foo.txt; - $* <'print */*.txt' >/'dir/foo.txt'; - $* <'print **.txt' >/'dir/foo.txt' : dir-interm-excl - - mkdir dir .dir && touch dir/foo.txt .dir/foo.txt; - $* <'print .*/*.txt' >/'.dir/foo.txt' : dir-interm-incl -} - -: expansion -: -: Test interaction with expansion/concatenation/re-parse. -{ - # Do we want to recognize patterns in non-concatenating expansion? - # - # pat = '*.txt' - # print $pat - # - # While this case is probably better rewritten as (i.e., move pattern search - # to variable assignment): - # - # pat = *.txt - # print $pat - # - # One may also want to do something like this: - # - # pat = '*.txt' - # print dir1/{$pat} - # print dir2/{$pat} - # - # Instead, he should write it as follows: - # - # pat = '*.txt' - # print dir1/{+$pat} - # print dir2/{+$pat} - # - # Note that if we make it work, escaping this case will be pretty hairy: - # - # filters = --include '*.txt' --exclude '*.obj' - # options += $filters - - : prefixed-pattern-via-expansion - : - : Pattern is prefixed with the literal unquoted plus character, that is - : stripped. - : - touch foo.txt; - $* <foo.txt - pat = '*.txt' - print {+$pat} - EOI - - : non-prefixed-pattern-via-concat-expansion - : - : Plus character is a part of the pattern and so is not stripped. - : - touch +foo.txt; - $* <'+foo.txt' - pat = '+*' - ext = 'txt' - print {$pat.$ext} - EOI - - : not-pattern-expansion - : - $* <'+*.txt' - pat = '+*.txt' - print {$pat} - EOI - - : not-pattern-quoted - : - $* <'+*.txt' - print {'+*.txt'} - EOI - - : pattern-via-expansion-list - : - touch foo.txt bar.hxx; - $* <'bar.hxx foo.txt' - pats = '*.hxx' '*.txt' - print {+{$pats}} - EOI - - : pattern-via-expansion-type - : - touch foo.txt; - $* <'txt{foo}' - pat = '*' - print txt{+$pat} - EOI - - : pattern-via-expansion-dir - : - mkdir dir; - touch dir/foo.txt; - $* <dir/foo.txt - pat = '*.txt' - print dir/{+$pat} - EOI - - : pattern-via-expansion-dir-type - : - mkdir dir; - touch dir/foo.txt; - $* <dir/txt{foo} - pat = '*' - print dir/txt{+$pat} - EOI - - : pattern-via-concat - : - touch foo.txt; - $* <'foo.txt' - ext = txt - print *.$ext - EOI - - : pattern-via-concat-expansion - : - touch foo.txt; - $* <'foo.txt' - pat = 'f*' - ext = txt - print $pat.$ext - EOI -} - -: command-line -: -: Test pattern expansion on the command line. -{ - : variable - : - { - mkdir dir; - $* <'print $d' 'd=*/' >/'dir/' : dir - - mkdir dir; - $* <'print $d' 'd=dir{*}' >/'dir{dir/}' : dir-type - - touch foo.txt; - $* <'print $f' 'f=*.txt' >'foo.txt' : feil - } - - : buildspec - : - { - test.arguments = - test.options += --buildfile buildfile - - mkdir dir && cat <'./:' >=dir/buildfile; - $* '*/' : dir - - mkdir dir dir1 && cat <'./:' >=dir/buildfile; - $* 'update(dir{* -dir1})' : dir-type - } -} diff --git a/tests/name/pattern.testscript b/tests/name/pattern.testscript new file mode 100644 index 0000000..d40e3a4 --- /dev/null +++ b/tests/name/pattern.testscript @@ -0,0 +1,332 @@ +# file : tests/name/pattern.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + ++cat <=build/root.build +define txt: file +txt{*}: extension = txt +EOI + +$* <'print pp%*.txt' >'pp%*.txt' : project-simple +$* <'print pp%{*.txt -x*}' >'pp%*.txt pp%-x*' : project-group + +$* <"print '*.txt'" >'*.txt' : quoted-single +$* <'print "*.txt"' >'*.txt' : quoted-double +$* <'*.txt' : quoted-expansion +pat = '*' +print "$(pat).txt" +EOI + +: detect +: +: Test pattern_mode parsing logic. +{ + : second-pattern + : + touch foo.txt; + $* <'print {foo *.txt}' >'foo foo.txt' + + : independent-patterns + : + touch foo.txt -bar; + $* <'print {*.txt foo* -b*}' >'foo.txt foo.txt -bar' + + : second-inclusion + : + touch foo.txt bar.txt; + $* <'print {f*.txt +b*.txt}' >'foo.txt bar.txt' +} + +: diagnostics +: +{ + : simple + : + $* <'print {*.txt +foo file{bar}}' 2>>EOE != 0 + :1:19: error: name pattern inclusion or exclusion expected + EOE + + : inclusion-exclusion-sign + : + $* <'print {*.txt -foo bar}' 2>>EOE != 0 + :1:19: error: name pattern inclusion or exclusion expected + EOE + + : inclusion-quoted + : + $* <'print {*.txt -foo "+bar"}' 2>>EOE != 0 + :1:19: error: name pattern inclusion or exclusion expected + EOE + + : empty-inclusion-exclusion + : + $* <'print {*.txt -}' 2>>EOE != 0 + :1:8: error: empty name pattern + EOE + + : inconsistent-result + : + $* <'print {*.txt +foo/}' 2>>EOE != 0 + :1:8: error: inconsistent file/directory result in name pattern + EOE +} + +: basics +: +{ + touch foo.txt; + $* <'print *.txt' >'foo.txt' : simple-file + + mkdir foo; + $* <'print */' >/'foo/' : simple-dir + + touch foo.txt; + $* <'print {*.txt}' >'foo.txt' : group + + touch foo.txt; + $* <'print {+*.txt}' >'foo.txt' : plus-prefixed + + mkdir dir && touch dir/foo.txt; + $* <'print dir/{*.txt}' >'dir/foo.txt' : dir + + touch foo.txt; + $* <'print file{*.txt}' >'file{foo.txt}' : type + + touch foo.txt; + $* <'print x@{*.txt}' >'x@foo.txt' : pair + + touch bar.txt; + $* <'print x@dir/file{f*.txt}' >'' : empty + + mkdir dir && touch dir/foo.txt; + $* <'print **.txt' >/'dir/foo.txt' : recursive + + mkdir dir && touch dir/foo.txt; + $* <'print d*/*.txt' >/'dir/foo.txt' : multi-pattern + + touch foo.txt bar.txt; + $* <'print {*.txt -bar.txt}' >'foo.txt' : exclude-non-pattern + + mkdir baz; + touch foo.txt bar.txt baz/fox.txt baz/box.txt; + $* <'print {**.txt -b*.txt -b*/*}' >'foo.txt' : exclude-pattern + + touch foo.txt bar.txt baz.txt; + $* <'print {*.txt -{*z.txt bar.txt}}' >'foo.txt' : exclude-group + + touch bar.txt; + $* <'print {f*.txt +bar.txt}' >'bar.txt' : include-non-wildcard + + touch bar.txt; + $* <'print {f*.txt +b*.txt}' >'bar.txt' : include-pattern + + mkdir bar; + $* <'print {f*/ +{b*/}}' >/'bar/' : include-group + + touch foo.txt fox.txt; + $* <'print {*.txt -f*.txt +*x.txt}' >'fox.txt' : include-exclude-order + + touch foo.txt; + $* <'print {+foo.txt} {+bar.txt}' >'foo.txt' : non-wildcard +} + +: target-type +: +: Test target type-specific pattern amendment logic. +{ + : append-extension + : + touch foo.txt bar.txt; + $* <'print txt{* -bar}' >'txt{foo}' + + : existing-extension + : + touch foo.txt bar.txt; + $* <'print txt{*.txt -bar.txt}' >'txt{foo.txt}' + + : append-slash + : + mkdir foo bar; + $* <'print dir{* -bar}' >/'dir{foo/}' + + : existing-slash + : + mkdir foo bar; + $* <'print dir{*/ -bar/}' >/'dir{foo/}' +} + +: dot +: +: Test filtering of hidden files/directories. +{ + touch foo.txt .foo.txt; + $* <'print *.txt' >'foo.txt' : file-excl + + touch foo.txt .foo.txt; + $* <'print .*.txt' >'.foo.txt' : file-incl + + mkdir dir .dir; + $* <'print */' >/'dir/' : dir-excl + + mkdir dir .dir; + $* <'print .*/' >/'.dir/' : dir-incl + + mkdir dir .dir && touch dir/foo.txt .dir/foo.txt; + $* <'print */*.txt' >/'dir/foo.txt'; + $* <'print **.txt' >/'dir/foo.txt' : dir-interm-excl + + mkdir dir .dir && touch dir/foo.txt .dir/foo.txt; + $* <'print .*/*.txt' >/'.dir/foo.txt' : dir-interm-incl +} + +: expansion +: +: Test interaction with expansion/concatenation/re-parse. +{ + # Do we want to recognize patterns in non-concatenating expansion? + # + # pat = '*.txt' + # print $pat + # + # While this case is probably better rewritten as (i.e., move pattern search + # to variable assignment): + # + # pat = *.txt + # print $pat + # + # One may also want to do something like this: + # + # pat = '*.txt' + # print dir1/{$pat} + # print dir2/{$pat} + # + # Instead, he should write it as follows: + # + # pat = '*.txt' + # print dir1/{+$pat} + # print dir2/{+$pat} + # + # Note that if we make it work, escaping this case will be pretty hairy: + # + # filters = --include '*.txt' --exclude '*.obj' + # options += $filters + + : prefixed-pattern-via-expansion + : + : Pattern is prefixed with the literal unquoted plus character, that is + : stripped. + : + touch foo.txt; + $* <foo.txt + pat = '*.txt' + print {+$pat} + EOI + + : non-prefixed-pattern-via-concat-expansion + : + : Plus character is a part of the pattern and so is not stripped. + : + touch +foo.txt; + $* <'+foo.txt' + pat = '+*' + ext = 'txt' + print {$pat.$ext} + EOI + + : not-pattern-expansion + : + $* <'+*.txt' + pat = '+*.txt' + print {$pat} + EOI + + : not-pattern-quoted + : + $* <'+*.txt' + print {'+*.txt'} + EOI + + : pattern-via-expansion-list + : + touch foo.txt bar.hxx; + $* <'bar.hxx foo.txt' + pats = '*.hxx' '*.txt' + print {+{$pats}} + EOI + + : pattern-via-expansion-type + : + touch foo.txt; + $* <'txt{foo}' + pat = '*' + print txt{+$pat} + EOI + + : pattern-via-expansion-dir + : + mkdir dir; + touch dir/foo.txt; + $* <dir/foo.txt + pat = '*.txt' + print dir/{+$pat} + EOI + + : pattern-via-expansion-dir-type + : + mkdir dir; + touch dir/foo.txt; + $* <dir/txt{foo} + pat = '*' + print dir/txt{+$pat} + EOI + + : pattern-via-concat + : + touch foo.txt; + $* <'foo.txt' + ext = txt + print *.$ext + EOI + + : pattern-via-concat-expansion + : + touch foo.txt; + $* <'foo.txt' + pat = 'f*' + ext = txt + print $pat.$ext + EOI +} + +: command-line +: +: Test pattern expansion on the command line. +{ + : variable + : + { + mkdir dir; + $* <'print $d' 'd=*/' >/'dir/' : dir + + mkdir dir; + $* <'print $d' 'd=dir{*}' >/'dir{dir/}' : dir-type + + touch foo.txt; + $* <'print $f' 'f=*.txt' >'foo.txt' : feil + } + + : buildspec + : + { + test.arguments = + test.options += --buildfile buildfile + + mkdir dir && cat <'./:' >=dir/buildfile; + $* '*/' : dir + + mkdir dir dir1 && cat <'./:' >=dir/buildfile; + $* 'update(dir{* -dir1})' : dir-type + } +} -- cgit v1.1