Inverted the boolean test from what I wanted it to be. Added a
[make.git] / tests / scripts / functions / wildcard
blobbcd84ad793a3ff40c7924422a455b95bea94a8b0
1 #                                                                    -*-perl-*-
3 $description = "The following test creates a makefile to test wildcard
4 expansions and the ability to put a command on the same
5 line as the target name separated by a semi-colon.";
7 $details = "\
8 This test creates 4 files by the names of 1.example,
9 two.example and 3.example.  We execute three tests.  The first
10 executes the print1 target which tests the '*' wildcard by
11 echoing all filenames by the name of '*.example'.  The second
12 test echo's all files which match '?.example' and
13 [a-z0-9].example.  Lastly we clean up all of the files using
14 the '*' wildcard as in the first test";
16 open(MAKEFILE,"> $makefile");
18 # The Contents of the MAKEFILE ...
20 print MAKEFILE <<EOM;
21 .PHONY: print1 print2 clean
22 print1: ;\@echo \$(sort \$(wildcard example.*))
23 print2:
24 \t\@echo \$(sort \$(wildcard example.?))
25 \t\@echo \$(sort \$(wildcard example.[a-z0-9]))
26 \t\@echo \$(sort \$(wildcard example.[!A-Za-z_\\!]))
27 clean:
28 \t$delete_command \$(sort \$(wildcard example.*))
29 EOM
31 # END of Contents of MAKEFILE
33 close(MAKEFILE);
35 &touch("example.1");
36 &touch("example.two");
37 &touch("example.3");
38 &touch("example.for");
39 &touch("example._");
41 # TEST #1
42 # -------
44 $answer = "example.1 example.3 example._ example.for example.two\n";
46 &run_make_with_options($makefile,"print1",&get_logfile);
48 &compare_output($answer,&get_logfile(1));
51 # TEST #2
52 # -------
54 $answer = "example.1 example.3 example._\n"
55          ."example.1 example.3\n"
56          ."example.1 example.3\n";
58 &run_make_with_options($makefile,"print2",&get_logfile);
60 &compare_output($answer,&get_logfile(1));
63 # TEST #3
64 # -------
66 $answer = "$delete_command example.1 example.3 example._ example.for example.two";
67 if ($vos)
69    $answer .= " \n";
71 else
73    $answer .= "\n";
76 &run_make_with_options($makefile,"clean",&get_logfile);
78 if ((-f "example.1")||(-f "example.two")||(-f "example.3")||(-f "example.for")) {
79    $test_passed = 0;
82 &compare_output($answer,&get_logfile(1));
84 # TEST #4: Verify that failed wildcards don't return the pattern
86 run_make_test(q!
87 all: ; @echo $(wildcard xz--y*.7)
89               '', "\n");
91 # TEST #5: wildcard used to verify file existence
93 touch('xxx.yyy');
95 run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!,
96               '', "file=xxx.yyy\n");
98 unlink('xxx.yyy');
100 run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!,
101               '', "file=\n");