]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - tests/makemakebuild.pl
postgresql testing
[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.3 2001-12-22 05:14:16 rurban 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 # reqirements: 
13 #  sun's java sdk, http://java.sun.com/j2se/
14 #  httpunit,       http://httpunit.sf.net
15 #  ant,            http://jakarta.apache.org/builds/jakarta-ant/release/
16
17 # usage:
18 #  copy the httpunit jars to this path or add them to your CLASSPATH
19 #  fix the url below for your server
20 #  run makemakebuild.pl, this creates Makefile (gnu make) and build.xml (ant)
21 #  run make, this compiles the classes and runs ant. 
22 #  if your classpath is wrong run ant seperately to test.
23 #  run ant for each test. both ant and make can run independently.
24
25 #my $my_wikiurl = 'http://reini/phpwiki/';  # this will replace steve's url below if defined
26 #-----------------------------------------
27
28 my $ori_wikiurl = 'http://127.0.0.1:8080/~swain/phpwiki/';
29 my @files = <*.inputs>;
30 chomp(@files); # prolly unnecessary, but oh well.
31
32 print "Found ", scalar(@files), " input files.\n";
33
34 foreach $inputfile (@files) {
35   $inputfile =~ m/\.inputs$/;
36   $javafile = "$`.java";
37   $classname = $`;
38   if ($my_wikiurl and ($my_wikiurl ne $ori_wikiurl)) {
39     local $/;
40     open IN, "< $inputfile";
41     $contents = <IN>;
42     `perl -i.orig -pe 's|$ori_wikiurl|$my_wikiurl|' $inputfile` if $contents =~ m|$ori_wikiurl|;
43   }
44
45   $test_make_target_names .= "$javafile ";
46   $test_make_targets .=<<"EOLN";
47 $javafile: $inputfile
48 \tmaketest.pl $inputfile
49
50 EOLN
51
52   $test_ant_targets .= <<"EOLN";
53   <target name="$classname">
54     <echo message="Testing with $classname..."/>
55     <java classname="$classname"></java>
56   </target>
57
58 EOLN
59
60   push @test_dependency_names, $classname;
61
62 }
63
64 $test_dependency_names = join(',', @test_dependency_names);
65
66 #  print <<"SHOW_RESULTS";
67 #    make's targets: $test_make_target_names
68
69 #    make's acutual targets:
70 #  $test_make_targets
71
72 #    ant's target names: $test_dependency_names
73
74 #    ant's targets:
75 #  $test_ant_targets
76
77 #  SHOW_RESULTS
78
79
80 # these are the skeleton files for the Makefile and the build.xml file
81
82 $makefile = <<MAKEFILE_SKEL;
83 # Generate new test classes if their input files have changed.
84 # This makefile is called from an Ant build.xml though you can run
85 # it by hand.
86
87 .SUFFIXES: .inputs .java .class .zip 
88 .PHONY: all clean buildtests dotest
89
90 tests = $test_make_target_names
91
92 # ANT_HOME=P:\\ant # path style os dependent!
93 CLASSPATH="httpunit.jar:Tidy.jar:classes.zip"
94
95 testsrc = \$(wildcard *.inputs)
96 javas   = \$(testsrc:.inputs=.java)
97 classes = \$(javas:.java=.class)
98 tests   = \$(javas:.java=)
99
100 all: buildtests classes.zip dotest
101
102 dotest: \$(classes)
103 \texport CLASSPATH=\$(CLASSPATH)
104 \tant 
105 #\tjava -classpath "\$(CLASSPATH):\${ANT_HOME}\\lib\\ant.jar" -Dant.home="\${ANT_HOME}" org.apache.tools.ant.Main \$(<:.class=)
106
107 buildtests: \$(javas) classes.zip
108
109 classes.zip: \$(classes)
110 \tzip \$@ \$?
111
112 clean:
113 \t-rm -f \$(javas) \$(classes) classes.zip
114
115 %.java : %.inputs
116 \tmaketest.pl \$<
117
118 %.class : %.java
119 \tjavac -classpath httpunit.jar \$<
120
121 MAKEFILE_SKEL
122
123
124 $buildxml = <<"BUILDXML_SKEL";
125 <project name="test" default="all">
126         
127    <target 
128       name="all"
129       depends="init,generate,compile,test">
130    </target>
131
132
133    <target name="init">
134       <tstamp/>
135    </target>
136
137    <target name="generate" depends="init">
138       <exec executable="make">
139          <arg line="buildtests"/>
140       </exec>
141    </target>
142
143
144
145    <target name="compile" depends="generate">
146       <javac srcdir="." destdir="." />
147    </target>
148
149
150    <target name="test" depends="compile,$test_dependency_names">
151    </target>
152
153
154    <target name="clean">
155
156       <exec executable="make">
157          <arg line="clean"/>
158       </exec>
159
160       <delete>
161          <fileset dir="." includes="*.class"/>
162       </delete>
163
164    </target>
165
166
167    <!-- individual test files are compiled here -->
168
169 $test_ant_targets
170
171 </project>
172 BUILDXML_SKEL
173
174
175 print "Writing Makefile...\n";
176 open MAKEFILE, ">./Makefile" or die $!;
177 print MAKEFILE $makefile;
178
179 print "Writing build.xml...\n";
180 open BUILDXML, ">./build.xml" or die $!;
181 print BUILDXML $buildxml;
182
183 print "Done.\n";