xref: /netbsd-src/external/gpl2/gmake/dist/tests/scripts/functions/wildcard (revision 69606e3f5c9388e52aed8c120ad63c049ca45d8f)
1*69606e3fSchristos#                                                                    -*-perl-*-
2*69606e3fSchristos
3*69606e3fSchristos$description = "The following test creates a makefile to test wildcard
4*69606e3fSchristosexpansions and the ability to put a command on the same
5*69606e3fSchristosline as the target name separated by a semi-colon.";
6*69606e3fSchristos
7*69606e3fSchristos$details = "\
8*69606e3fSchristosThis test creates 4 files by the names of 1.example,
9*69606e3fSchristostwo.example and 3.example.  We execute three tests.  The first
10*69606e3fSchristosexecutes the print1 target which tests the '*' wildcard by
11*69606e3fSchristosechoing all filenames by the name of '*.example'.  The second
12*69606e3fSchristostest echo's all files which match '?.example' and
13*69606e3fSchristos[a-z0-9].example.  Lastly we clean up all of the files using
14*69606e3fSchristosthe '*' wildcard as in the first test";
15*69606e3fSchristos
16*69606e3fSchristosopen(MAKEFILE,"> $makefile");
17*69606e3fSchristos
18*69606e3fSchristos# The Contents of the MAKEFILE ...
19*69606e3fSchristos
20*69606e3fSchristosprint MAKEFILE <<EOM;
21*69606e3fSchristos.PHONY: print1 print2 clean
22*69606e3fSchristosprint1: ;\@echo \$(sort \$(wildcard example.*))
23*69606e3fSchristosprint2:
24*69606e3fSchristos\t\@echo \$(sort \$(wildcard example.?))
25*69606e3fSchristos\t\@echo \$(sort \$(wildcard example.[a-z0-9]))
26*69606e3fSchristos\t\@echo \$(sort \$(wildcard example.[!A-Za-z_\\!]))
27*69606e3fSchristosclean:
28*69606e3fSchristos\t$delete_command \$(sort \$(wildcard example.*))
29*69606e3fSchristosEOM
30*69606e3fSchristos
31*69606e3fSchristos# END of Contents of MAKEFILE
32*69606e3fSchristos
33*69606e3fSchristosclose(MAKEFILE);
34*69606e3fSchristos
35*69606e3fSchristos&touch("example.1");
36*69606e3fSchristos&touch("example.two");
37*69606e3fSchristos&touch("example.3");
38*69606e3fSchristos&touch("example.for");
39*69606e3fSchristos&touch("example._");
40*69606e3fSchristos
41*69606e3fSchristos# TEST #1
42*69606e3fSchristos# -------
43*69606e3fSchristos
44*69606e3fSchristos$answer = "example.1 example.3 example._ example.for example.two\n";
45*69606e3fSchristos
46*69606e3fSchristos&run_make_with_options($makefile,"print1",&get_logfile);
47*69606e3fSchristos
48*69606e3fSchristos&compare_output($answer,&get_logfile(1));
49*69606e3fSchristos
50*69606e3fSchristos
51*69606e3fSchristos# TEST #2
52*69606e3fSchristos# -------
53*69606e3fSchristos
54*69606e3fSchristos$answer = "example.1 example.3 example._\n"
55*69606e3fSchristos         ."example.1 example.3\n"
56*69606e3fSchristos         ."example.1 example.3\n";
57*69606e3fSchristos
58*69606e3fSchristos&run_make_with_options($makefile,"print2",&get_logfile);
59*69606e3fSchristos
60*69606e3fSchristos&compare_output($answer,&get_logfile(1));
61*69606e3fSchristos
62*69606e3fSchristos
63*69606e3fSchristos# TEST #3
64*69606e3fSchristos# -------
65*69606e3fSchristos
66*69606e3fSchristos$answer = "$delete_command example.1 example.3 example._ example.for example.two";
67*69606e3fSchristosif ($vos)
68*69606e3fSchristos{
69*69606e3fSchristos   $answer .= " \n";
70*69606e3fSchristos}
71*69606e3fSchristoselse
72*69606e3fSchristos{
73*69606e3fSchristos   $answer .= "\n";
74*69606e3fSchristos}
75*69606e3fSchristos
76*69606e3fSchristos&run_make_with_options($makefile,"clean",&get_logfile);
77*69606e3fSchristos
78*69606e3fSchristosif ((-f "example.1")||(-f "example.two")||(-f "example.3")||(-f "example.for")) {
79*69606e3fSchristos   $test_passed = 0;
80*69606e3fSchristos}
81*69606e3fSchristos
82*69606e3fSchristos&compare_output($answer,&get_logfile(1));
83*69606e3fSchristos
84*69606e3fSchristos
85*69606e3fSchristos1;
86*69606e3fSchristos
87*69606e3fSchristos
88*69606e3fSchristos
89*69606e3fSchristos
90*69606e3fSchristos
91*69606e3fSchristos
92*69606e3fSchristos
93*69606e3fSchristos
94*69606e3fSchristos
95