From a68fa2f5c22cbbfc099dd77cccaf44db4cf85730 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 12 Nov 2020 14:38:12 +0200 Subject: Generalize dot escaping in target name rules Now triple dot and escape sequence can appear almost anywhere in the target name (see target::split_name() for details). --- tests/name/extension.testscript | 243 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 223 insertions(+), 20 deletions(-) (limited to 'tests/name') diff --git a/tests/name/extension.testscript b/tests/name/extension.testscript index 72721c2..1583109 100644 --- a/tests/name/extension.testscript +++ b/tests/name/extension.testscript @@ -16,46 +16,238 @@ EOI : unspecified : touch foo.txt; - $* <'./: txt{foo}' + $* <>EOO + ./: txt{foo} + print $name(txt{foo}) + print $extension(txt{foo}) + print txt{fo?} + EOI + foo + [null] + txt{foo} + EOO : specified : touch foo.text; - $* <'./: txt{foo.text}' + $* <>EOO + ./: txt{foo.text} + print $name(txt{foo.text}) + print $extension(txt{foo.text}) + print txt{fo?.text} + EOI + foo + text + txt{foo.text} + EOO - : specified-none + : specified-triple : - touch foo; - $* <'./: txt{foo.}' + touch fo.o.text; + $* <>EOO + ./: txt{fo...o.text} + print $name(txt{fo...o.text}) + print $extension(txt{fo...o.text}) + print txt{f?...o.text} + EOI + fo + o.text + txt{fo...o.text} + EOO - : specified-default + : multiple-triples : - touch foo.testscript.txt; - $* <'./: txt{foo.testscript...}' + $* <'./: txt{f...o...o}' 2>>EOE != 0 + :1:5: error: multiple triple dots in target name 'f...o...o' + EOE - # Trailing dots are not allowed on Windows. - # + : multiple-singles + : + touch fo.o.text; + $* <>EOO + ./: txt{fo.o.text} + print $name(txt{fo.o.text}) + print $extension(txt{fo.o.text}) + print txt{f?.o.text} + EOI + fo.o + text + txt{fo.o.text} + EOO - : specified-escape-one + : escape-basename + : + touch fo.o.text; + $* <>EOO + ./: txt{fo..o.text} + print $name(txt{fo..o.text}) + print $extension(txt{fo..o.text}) + print txt{f?..o.text} + EOI + fo.o + text + txt{fo.o.text} + EOO + + : escape-extension + : + touch fo.o.text; + $* <>EOO + ./: txt{fo.o..text} + print $name(txt{fo.o..text}) + print $extension(txt{fo.o..text}) + print txt{f?.o..text} + EOI + fo + o.text + txt{fo...o.text} + EOO + + : trailing : - if ($cxx.target.class != 'windows') { - touch foo.; - $* <'./: txt{foo..}' + : no-extension + : + touch foo; + $* <>EOO + ./: txt{foo.} + print $name(txt{foo.}) + print $extension(txt{foo.}) + print txt{fo?.} + EOI + foo + + txt{foo.} + EOO + + : dot-no-extension + : + touch f.oo; + $* <>EOO + ./: txt{f.oo.} + print $name(txt{f.oo.}) + print $extension(txt{f.oo.}) + print txt{f.o?.} + EOI + f.oo + + txt{f.oo.} + EOO + + : default-extension + : + touch foo.testscript.txt; + $* <>EOO + ./: txt{foo.testscript...} + print $name(txt{foo.testscript...}) + print $extension(txt{foo.testscript...}) + print txt{fo?.testscript...} + EOI + foo.testscript + [null] + txt{foo.testscript...} + EOO + + # Trailing dots are not allowed on Windows. + # + + : escape-one + : + if ($cxx.target.class != 'windows') + { + touch foo.; + $* <>EOO + ./: txt{foo..} + print $name(txt{foo..}) + print $extension(txt{foo..}) + print txt{fo?..} + EOI + foo. + + txt{foo..} + EOO + } + + : escape-two + : + if ($cxx.target.class != 'windows') + { + touch foo..; + $* <>EOO + ./: txt{foo....} + print $name(txt{foo....}) + print $extension(txt{foo....}) + print txt{fo?....} + EOI + foo.. + + txt{foo....} + EOO + } } - : specified-escape-two + : leading : - if ($cxx.target.class != 'windows') { - touch foo..; - $* <'./: txt{foo....}' + : single + : + touch .foo.txt; + $* <>EOO + ./: txt{.foo} + print $name(txt{.foo}) + print $extension(txt{.foo}) + print txt{.fo?} + EOI + .foo + [null] + txt{.foo} + EOO + + : triple + : + $* <'./: txt{...foo}' 2>>EOE != 0 + :1:5: error: leading triple dots in target name '...foo' + EOE + + : escape-one + : + touch .foo.txt; + $* <>EOO + ./: txt{..foo} + print $name(txt{..foo}) + print $extension(txt{..foo}) + print txt{..fo?} + EOI + .foo + [null] + txt{.foo} + EOO + + : escape-two + : + touch ..foo.txt; + $* <>EOO + ./: txt{....foo} + print $name(txt{....foo}) + print $extension(txt{....foo}) + print txt{....fo?} + EOI + ..foo + [null] + txt{....foo} + EOO } : specified-invalid : - $* <'./: txt{foo.....}' 2>>EOE != 0 - :1:5: error: invalid trailing dot sequence in target name 'foo.....' + $* <'./: txt{fo.....o}' 2>>EOE != 0 + :1:5: error: invalid dot sequence in target name 'fo.....o' + EOE + + : specified-dot-only + : + $* <'./: txt{..}' 2>>EOE != 0 + :1:5: error: invalid target name '..' EOE } @@ -72,6 +264,17 @@ EOI touch foo.testscript.txt; $* <'print txt{fo?.testscript...}' >'txt{foo.testscript...}' + : dir + : + touch foo.txt; + $* <'print txt{./f*}' >'txt{./foo}' + + : dir-leading-triple + : + $* <'print txt{./...f*}' 2>>EOE != 0 + :1:11: error: leading triple dots in target name './...f*' + EOE + # Trailing dots are not allowed on Windows. # -- cgit v1.1