]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - tests/makemakebuild.pl
Simple test to verify text appears in the source of a page.
[SourceForge/phpwiki.git] / tests / makemakebuild.pl
1 #!/usr/bin/perl
2
3 #  Write out a Makefile and a build.xml file based on the *.inputs files
4 #  in the current directory. Steve Wainstead, April 2001.
5
6 # $Id: makemakebuild.pl,v 1.1 2001-09-20 20:52:22 wainstead Exp $
7
8 # read in all the input files, loop over each one and build up 
9 # text blocks that we will subsitute into the skeletons for Makefile
10 # and build.xml.
11
12 my @files = <*.inputs>;
13 chomp(@files); # prolly unnecessary, but oh well.
14
15 print "Found ", scalar(@files), " input files.\n";
16
17 foreach $inputfile (@files) {
18   $inputfile =~ m/\.inputs$/;
19   $javafile = "$`.java";
20   $classname = $`;
21
22   $test_make_target_names .= "$javafile ";
23   $test_make_targets .=<<"EOLN";
24 $javafile: $inputfile
25 \tmaketest.pl $inputfile
26
27 EOLN
28
29   $test_ant_targets .= <<"EOLN";
30   <target name="$classname">
31     <echo message="Testing with $classname..."/>
32     <java classname="$classname"></java>
33   </target>
34
35 EOLN
36
37   push @test_dependency_names, $classname;
38
39 }
40
41 $test_dependency_names = join(',', @test_dependency_names);
42
43 #  print <<"SHOW_RESULTS";
44 #    make's targets: $test_make_target_names
45
46 #    make's acutual targets:
47 #  $test_make_targets
48
49 #    ant's target names: $test_dependency_names
50
51 #    ant's targets:
52 #  $test_ant_targets
53
54 #  SHOW_RESULTS
55
56
57 # these are the skeleton files for the Makefile and the build.xml file
58
59 $makefile = <<MAKEFILE_SKEL;
60 # Generate new test classes if their input files have changed.
61 # This makefile is called from an Ant build.xml though you can run
62 # it by hand.
63
64 tests = $test_make_target_names
65
66 all: \$(tests)
67
68 $test_make_targets
69
70 .PHONY: clean
71 clean:
72 \t-rm -f *.java
73
74 MAKEFILE_SKEL
75
76
77 $buildxml = <<"BUILDXML_SKEL";
78 <project name="test" default="all">
79         
80    <target 
81       name="all"
82       depends="init,generate,compile,test">
83    </target>
84
85
86    <target name="init">
87       <tstamp/>
88    </target>
89
90    <target name="generate" depends="init">
91       <exec executable="make">
92       </exec>
93    </target>
94
95
96
97    <target name="compile" depends="generate">
98       <javac srcdir="." destdir="." />
99    </target>
100
101
102    <target name="test" depends="compile,$test_dependency_names">
103    </target>
104
105
106    <target name="clean">
107
108       <exec executable="make">
109          <arg line="clean"/>
110       </exec>
111
112       <delete>
113          <fileset dir="." includes="*.class"/>
114       </delete>
115
116    </target>
117
118
119    <!-- individual test files are compiled here -->
120
121 $test_ant_targets
122
123 </project>
124 BUILDXML_SKEL
125
126
127 print "Writing Makefile...\n";
128 open MAKEFILE, ">./Makefile" or die $!;
129 print MAKEFILE $makefile;
130
131 print "Writing build.xml...\n";
132 open BUILDXML, ">./build.xml" or die $!;
133 print BUILDXML $buildxml;
134
135 print "Done.\n";