1999-09-14 02:03:19 +00:00
|
|
|
# -*-perl-*-
|
|
|
|
|
2002-10-03 05:46:12 +00:00
|
|
|
$description = "The following test creates a makefile to test wildcard
|
|
|
|
expansions and the ability to put a command on the same
|
|
|
|
line as the target name separated by a semi-colon.";
|
1999-09-14 02:03:19 +00:00
|
|
|
|
2002-10-03 05:46:12 +00:00
|
|
|
$details = "\
|
|
|
|
This test creates 4 files by the names of 1.example,
|
|
|
|
two.example and 3.example. We execute three tests. The first
|
|
|
|
executes the print1 target which tests the '*' wildcard by
|
|
|
|
echoing all filenames by the name of '*.example'. The second
|
|
|
|
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";
|
1999-09-14 02:03:19 +00:00
|
|
|
|
2019-09-02 15:06:40 +00:00
|
|
|
touch("example.1");
|
|
|
|
touch("example.two");
|
|
|
|
touch("example.3");
|
|
|
|
touch("example.for");
|
|
|
|
touch("example._");
|
1999-09-14 02:03:19 +00:00
|
|
|
|
2019-09-02 15:06:40 +00:00
|
|
|
# TEST #1
|
|
|
|
# -------
|
1999-09-14 02:03:19 +00:00
|
|
|
|
2019-09-02 15:06:40 +00:00
|
|
|
run_make_test(qq/
|
2002-10-03 05:46:12 +00:00
|
|
|
.PHONY: print1 print2 clean
|
2019-09-02 15:06:40 +00:00
|
|
|
print1: ;\@echo \$(wildcard example.*)
|
1999-09-14 02:03:19 +00:00
|
|
|
print2:
|
2019-09-02 15:06:40 +00:00
|
|
|
\t\@echo \$(wildcard example.?)
|
|
|
|
\t\@echo \$(wildcard example.[a-z0-9])
|
|
|
|
\t\@echo \$(wildcard example.[!A-Za-z_\\!])
|
1999-09-14 02:03:19 +00:00
|
|
|
clean:
|
2019-09-02 15:06:40 +00:00
|
|
|
\t$CMD_rmfile \$(wildcard example.*)
|
|
|
|
/,
|
|
|
|
'print1', "example.1 example.3 example._ example.for example.two\n");
|
1999-09-14 02:03:19 +00:00
|
|
|
|
|
|
|
# TEST #2
|
|
|
|
# -------
|
|
|
|
|
2019-09-02 15:06:40 +00:00
|
|
|
run_make_test(undef, 'print2', "example.1 example.3 example._\n"
|
|
|
|
."example.1 example.3\n"
|
|
|
|
."example.1 example.3\n");
|
1999-09-14 02:03:19 +00:00
|
|
|
|
|
|
|
# TEST #3
|
|
|
|
# -------
|
|
|
|
|
2016-12-23 18:33:58 +00:00
|
|
|
$answer = "$CMD_rmfile example.1 example.3 example._ example.for example.two";
|
1999-09-14 02:03:19 +00:00
|
|
|
if ($vos)
|
|
|
|
{
|
|
|
|
$answer .= " \n";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$answer .= "\n";
|
|
|
|
}
|
|
|
|
|
2019-09-02 15:06:40 +00:00
|
|
|
run_make_test(undef, 'clean', $answer);
|
2004-05-16 19:16:52 +00:00
|
|
|
|
2009-06-13 21:21:48 +00:00
|
|
|
# TEST #4: Verify that failed wildcards don't return the pattern
|
1999-09-14 02:03:19 +00:00
|
|
|
|
2009-06-13 21:21:48 +00:00
|
|
|
run_make_test(q!
|
|
|
|
all: ; @echo $(wildcard xz--y*.7)
|
|
|
|
!,
|
|
|
|
'', "\n");
|
1999-09-14 02:03:19 +00:00
|
|
|
|
2011-05-07 14:36:11 +00:00
|
|
|
# TEST #5: wildcard used to verify file existence
|
|
|
|
|
|
|
|
touch('xxx.yyy');
|
|
|
|
|
2019-09-02 15:10:56 +00:00
|
|
|
run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!, '', "file=xxx.yyy\n");
|
2011-05-07 14:36:11 +00:00
|
|
|
|
|
|
|
unlink('xxx.yyy');
|
|
|
|
|
2019-09-02 15:10:56 +00:00
|
|
|
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.
|
2019-10-05 18:45:45 +00:00
|
|
|
#
|
|
|
|
# Currently this doesn't work with our embedded GLOB so disable it.
|
2019-09-02 15:10:56 +00:00
|
|
|
# -------
|
|
|
|
|
2019-10-05 18:45:45 +00:00
|
|
|
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!
|
2019-09-02 15:10:56 +00:00
|
|
|
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]/)
|
|
|
|
!, '',
|
2019-10-05 18:45:45 +00:00
|
|
|
"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') {
|
2019-09-02 15:10:56 +00:00
|
|
|
rmdir($d);
|
2019-10-05 18:45:45 +00:00
|
|
|
}
|
2019-09-02 15:10:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($port_type ne 'W32') {
|
2019-10-05 18:45:45 +00:00
|
|
|
# Check wildcard on the root directory
|
|
|
|
run_make_test('print4: ; @echo $(wildcard /)', '', "/\n");
|
2019-09-02 15:10:56 +00:00
|
|
|
}
|
2011-05-07 14:36:11 +00:00
|
|
|
|
2018-08-04 18:04:44 +00:00
|
|
|
if ($port_type ne 'W32' && eval { symlink("",""); 1 }) {
|
2018-08-04 21:35:10 +00:00
|
|
|
|
2019-10-05 18:45:45 +00:00
|
|
|
# TEST #6: check for wildcards matching directories
|
|
|
|
# See SV 53465
|
2018-08-04 21:35:10 +00:00
|
|
|
|
2019-10-05 18:45:45 +00:00
|
|
|
my $dir = '__rdir';
|
|
|
|
my $lnk = '__ldir';
|
|
|
|
mkdir($dir, 0777);
|
|
|
|
symlink($dir, $lnk);
|
2018-08-04 18:04:44 +00:00
|
|
|
|
2019-10-05 18:45:45 +00:00
|
|
|
run_make_test(qq!all: ; \@echo \$(wildcard $lnk*/.)!, '', "$lnk/.");
|
2018-08-04 18:04:44 +00:00
|
|
|
|
2019-10-05 18:45:45 +00:00
|
|
|
unlink($lnk);
|
|
|
|
rmdir($dir);
|
2018-08-04 21:35:10 +00:00
|
|
|
|
2019-10-05 18:45:45 +00:00
|
|
|
# Test for dangling symlinks
|
|
|
|
# This doesn't work with the built-in glob... needs to be updated!
|
2018-08-04 21:35:10 +00:00
|
|
|
|
2019-10-05 18:45:45 +00:00
|
|
|
if (get_config('USE_SYSTEM_GLOB') eq 'yes') {
|
|
|
|
symlink($dir, $lnk);
|
2018-08-04 21:35:10 +00:00
|
|
|
|
2019-10-05 18:45:45 +00:00
|
|
|
run_make_test(qq!all: ; \@echo \$(wildcard $lnk)!, '', "$lnk");
|
2018-08-04 21:35:10 +00:00
|
|
|
|
2019-10-05 18:45:45 +00:00
|
|
|
unlink($lnk);
|
|
|
|
}
|
2018-08-04 18:04:44 +00:00
|
|
|
}
|
|
|
|
|
2009-06-13 21:21:48 +00:00
|
|
|
1;
|