diff options
author | JinWang An <jinwang.an@samsung.com> | 2021-12-28 15:15:18 +0900 |
---|---|---|
committer | JinWang An <jinwang.an@samsung.com> | 2021-12-28 15:15:18 +0900 |
commit | b11e2699c7ec42e6d2fc0f4c940f14e7c89b3974 (patch) | |
tree | 14002517ee70130303762f511b4d1b50251267ca /tests/scripts/functions/wildcard | |
parent | 0a1cba99f5ce73ae0cacdbf9ab1186137efd77f7 (diff) | |
download | make-b11e2699c7ec42e6d2fc0f4c940f14e7c89b3974.tar.gz make-b11e2699c7ec42e6d2fc0f4c940f14e7c89b3974.tar.bz2 make-b11e2699c7ec42e6d2fc0f4c940f14e7c89b3974.zip |
Imported Upstream version 4.3upstream/4.3
Diffstat (limited to 'tests/scripts/functions/wildcard')
-rw-r--r-- | tests/scripts/functions/wildcard | 158 |
1 files changed, 109 insertions, 49 deletions
diff --git a/tests/scripts/functions/wildcard b/tests/scripts/functions/wildcard index bcd84ad..f01f574 100644 --- a/tests/scripts/functions/wildcard +++ b/tests/scripts/functions/wildcard @@ -13,57 +13,38 @@ test echo's all files which match '?.example' and [a-z0-9].example. Lastly we clean up all of the files using the '*' wildcard as in the first test"; -open(MAKEFILE,"> $makefile"); +touch("example.1"); +touch("example.two"); +touch("example.3"); +touch("example.for"); +touch("example._"); -# The Contents of the MAKEFILE ... +# TEST #1 +# ------- -print MAKEFILE <<EOM; +run_make_test(qq/ .PHONY: print1 print2 clean -print1: ;\@echo \$(sort \$(wildcard example.*)) +print1: ;\@echo \$(wildcard example.*) print2: -\t\@echo \$(sort \$(wildcard example.?)) -\t\@echo \$(sort \$(wildcard example.[a-z0-9])) -\t\@echo \$(sort \$(wildcard example.[!A-Za-z_\\!])) +\t\@echo \$(wildcard example.?) +\t\@echo \$(wildcard example.[a-z0-9]) +\t\@echo \$(wildcard example.[!A-Za-z_\\!]) clean: -\t$delete_command \$(sort \$(wildcard example.*)) -EOM - -# END of Contents of MAKEFILE - -close(MAKEFILE); - -&touch("example.1"); -&touch("example.two"); -&touch("example.3"); -&touch("example.for"); -&touch("example._"); - -# TEST #1 -# ------- - -$answer = "example.1 example.3 example._ example.for example.two\n"; - -&run_make_with_options($makefile,"print1",&get_logfile); - -&compare_output($answer,&get_logfile(1)); - +\t$CMD_rmfile \$(wildcard example.*) +/, + 'print1', "example.1 example.3 example._ example.for example.two\n"); # TEST #2 # ------- -$answer = "example.1 example.3 example._\n" - ."example.1 example.3\n" - ."example.1 example.3\n"; - -&run_make_with_options($makefile,"print2",&get_logfile); - -&compare_output($answer,&get_logfile(1)); - +run_make_test(undef, 'print2', "example.1 example.3 example._\n" + ."example.1 example.3\n" + ."example.1 example.3\n"); # TEST #3 # ------- -$answer = "$delete_command example.1 example.3 example._ example.for example.two"; +$answer = "$CMD_rmfile example.1 example.3 example._ example.for example.two"; if ($vos) { $answer .= " \n"; @@ -73,13 +54,7 @@ else $answer .= "\n"; } -&run_make_with_options($makefile,"clean",&get_logfile); - -if ((-f "example.1")||(-f "example.two")||(-f "example.3")||(-f "example.for")) { - $test_passed = 0; -} - -&compare_output($answer,&get_logfile(1)); +run_make_test(undef, 'clean', $answer); # TEST #4: Verify that failed wildcards don't return the pattern @@ -92,12 +67,97 @@ all: ; @echo $(wildcard xz--y*.7) touch('xxx.yyy'); -run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!, - '', "file=xxx.yyy\n"); +run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!, '', "file=xxx.yyy\n"); unlink('xxx.yyy'); -run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!, - '', "file=\n"); +run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!, '', "file=\n"); + +# TEST #7: verify that when the input pattern has a trailing slash wildcard +# returns only directories. +# +# Currently this doesn't work with our embedded GLOB so disable it. +# ------- + +if (get_config('USE_SYSTEM_GLOB') eq 'yes') { + touch("hellof"); + mkdir("hellod", 0770); + mkdir("hellod/worldd", 0770); + touch("hellod/worldf"); + mkdir("hellod/worldd/kend1", 0770); + mkdir("hellod/worldd/kend2", 0770); + touch("hellod/worldd/kenf1"); + touch("hellod/worldd/kenf2"); + + run_make_test(qq! +print3: +\t\@echo \$(wildcard hello*) +\t\@echo \$(wildcard hello*/) +\t\@echo \$(wildcard hellod/world*) +\t\@echo \$(wildcard hellod/world*/) +\t\@echo \$(wildcard hello* hellod/world*) +\t\@echo \$(wildcard hello*/ hellod/world*/) +\t\@echo \$(wildcard hellod/*) +\t\@echo \$(wildcard hellod/*/) +\t\@echo \$(wildcard */world*) +\t\@echo \$(wildcard */worldd/) +\t\@echo \$(wildcard hellod/*/ken*/) +\t\@echo \$(wildcard hellod/*/ken?[12]) +\t\@echo \$(wildcard hellod/*/ken?[12]/) +!, '', + "hellod hellof\n" + ."hellod/\n" + ."hellod/worldd hellod/worldf\n" + ."hellod/worldd/\n" + ."hellod hellof hellod/worldd hellod/worldf\n" + ."hellod/ hellod/worldd/\n" + ."hellod/worldd hellod/worldf\n" + ."hellod/worldd/\n" + ."hellod/worldd hellod/worldf\n" + ."hellod/worldd/\n" + ."hellod/worldd/kend1/ hellod/worldd/kend2/\n" + ."hellod/worldd/kend1 hellod/worldd/kend2 " + ."hellod/worldd/kenf1 hellod/worldd/kenf2\n" + ."hellod/worldd/kend1/ hellod/worldd/kend2/\n"); + + unlink('hellof', 'hellod/worldf', 'hellod/worldd/kenf1', + 'hellod/worldd/kenf2'); + foreach $d ('hellod/worldd/kend1', 'hellod/worldd/kend2', 'hellod/worldd', + 'hellod') { + rmdir($d); + } +} + +if ($port_type ne 'W32') { + # Check wildcard on the root directory + run_make_test('print4: ; @echo $(wildcard /)', '', "/\n"); +} + +if ($port_type ne 'W32' && eval { symlink("",""); 1 }) { + + # TEST #6: check for wildcards matching directories + # See SV 53465 + + my $dir = '__rdir'; + my $lnk = '__ldir'; + mkdir($dir, 0777); + symlink($dir, $lnk); + + run_make_test(qq!all: ; \@echo \$(wildcard $lnk*/.)!, '', "$lnk/."); + + unlink($lnk); + rmdir($dir); + + # Test for dangling symlinks + # This doesn't work with the built-in glob... needs to be updated! + + if (get_config('USE_SYSTEM_GLOB') eq 'yes') { + symlink($dir, $lnk); + + run_make_test(qq!all: ; \@echo \$(wildcard $lnk)!, '', "$lnk"); + + unlink($lnk); + } +} 1; |