aboutsummaryrefslogtreecommitdiffstats
path: root/infrastructure/rhino1_7R1/testsrc/build.xml
blob: bc0551658a22c8aac25798d7c99883b433353a19 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?xml version="1.0" encoding="UTF-8"?>
<project name="testsrc" basedir="..">
  <!--
    Location of mozilla/js/tests directory
  -->
  <property name="test.library.dir" location="../tests" />

  <!--
    Destination to which testing classes should be built
  -->
  <property name="test.classes" value="${build.dir}/test/classes" />

  <!--
    Output directory for HTML files generated by jsdriver
  -->
  <property name="test.output" value="${build.dir}/test/output" />

  <!--
    Timeout in milliseconds for tests
  -->
  <property name="test.timeout" value="60000" />

  <!--
    Maximum heap size for VM executing test cases.
  -->
  <property name="test.vm.mx" value="256m" />

  <target name="junit-compile">
    <mkdir dir="${test.classes}" />
    <get src="http://mirrors.ibiblio.org/pub/mirrors/maven2/junit/junit/3.8.2/junit-3.8.2.jar" dest="lib/junit.jar" usetimestamp="true"/>
    <javac
      srcdir="testsrc"
      destdir="${test.classes}" debug="true"
      target="${target-jvm}"
      source="${source-level}"
    >
      <classpath>
        <pathelement path="lib/junit.jar" />
        <pathelement path="${classes}" />
        <pathelement path="${test-classes}" />
      </classpath>
         <include name="org/mozilla/javascript/drivers/StandardTests.java" />
    </javac>
    <antcall target="copy-files" />
  </target>

  <target name="compile">
    <mkdir dir="${test.classes}" />
    <javac
      srcdir="testsrc"
      destdir="${test.classes}" debug="true"
      target="${target-jvm}"
      source="${source-level}"
    >
      <classpath>
        <pathelement path="${classes}" />
      </classpath>
      <sourcepath path="testsrc" />
        <include name="org/mozilla/javascript/drivers/JsDriver.java" />
    </javac>
    <antcall target="copy-files" />
  </target>

  <target name="copy-files">
    <copy todir="${test.classes}">
       <fileset dir="testsrc">
         <exclude name="**/*.java build.xml"/>
       </fileset>
    </copy>
  </target>
  	
  <target name="clean">
    <delete dir="${test.classes}" />
  </target>

  <target name="coverage-instrument">
    <get src="http://mirrors.ibiblio.org/pub/mirrors/maven2/emma/emma/2.0.5312/emma-2.0.5312.jar" dest="lib/emma.jar" usetimestamp="true"/>
    <get src="http://mirrors.ibiblio.org/pub/mirrors/maven2/emma/emma_ant/2.0.5312/emma_ant-2.0.5312.jar" dest="lib/emma_ant.jar" usetimestamp="true"/>
    <property name="coverage.dir" location="${build.dir}/coverage"/>
    <property name="coverage.classes.dir" location="${build.dir}/coverage/classes"/>
    <mkdir dir="${coverage.classes.dir}"/>
    <path id="emma.lib">
      <pathelement location="lib/emma.jar" />
      <pathelement location="lib/emma_ant.jar" />
    </path>
    <taskdef resource="emma_ant.properties" classpathref="emma.lib" />
    <property name="coverage.instrumentationfile" location="${coverage.dir}/instrumentation"/>
    <emma enabled="true">
      <instr 
        instrpath="${classes}" outdir="${coverage.classes.dir}" 
        outfile="${coverage.instrumentationfile}" mode="copy"/>
    </emma>
    <copy todir="${coverage.classes.dir}">
      <fileset dir="src" excludes="**/*.java"/>
    </copy>
    <copy todir="${coverage.classes.dir}">
      <fileset dir="${classes}"/>
    </copy>
    <property name="coverage.outfile" location="${coverage.dir}/coverage"/>
  </target>
	
  <target name="junit" depends="junit-compile,coverage-instrument">
    <junit printsummary="on" fork="true" forkmode="once" maxmemory="${test.vm.mx}" showoutput="true">
      <sysproperty key="java.awt.headless" value="true" />
      <sysproperty key="mozilla.js.tests" value="${test.library.dir}" />
      <sysproperty key="mozilla.js.tests.timeout" value="${test.timeout}" />
      <sysproperty key="emma.coverage.out.file" value="${coverage.outfile}"/>
      <classpath>
        <pathelement location="${xbean.jar}"/>
        <pathelement location="${jsr173.jar}"/>
      	<pathelement path="${coverage.classes.dir}" />
        <pathelement path="${classes}" />
        <pathelement path="${test.classes}" />
     	<pathelement path="lib/emma.jar"/>
        <pathelement path="lib/junit.jar" />
      </classpath>
      <batchtest todir="build/test">
        <fileset dir="${test.classes}" includes="**/*Tests.class"/>
      </batchtest>
      <formatter type="plain" usefile="false" />
      <formatter type="xml"/>
    </junit>
    <mkdir dir="build/test/report"/>
    <junitreport todir="build/test/report">
       <fileset dir="build/test" includes="*.xml"/>
       <report todir="build/test/report"/>
    </junitreport>
  </target>

  <target name="junit-coveragereport" depends="junit">
    <property name="coverage.report.dir" location="${build.dir}/coverage/report"/>
    <mkdir dir="${coverage.report.dir}"/>
    <delete dir="${coverage.report.dir}"/>
    <mkdir dir="${coverage.report.dir}"/>
    <emma enabled="true">
      <report>
        <fileset dir="${basedir}">
          <include name="build/coverage/instrumentation"/>
          <include name="build/coverage/coverage"/>
        </fileset>
        <sourcepath>
          <dirset dir="${basedir}">
            <include name="src"/>
          </dirset>
        </sourcepath>
        <html outfile="${coverage.report.dir}/index.html"/>
      </report>
    </emma>
  </target>

  <target name="jsdriver" depends="compile">
    <tstamp>
      <format property="test.timestamp" pattern="yyyy.MM.dd.HH.mm.ss" />
    </tstamp>
    <mkdir dir="${test.output}" />
    <java
      fork="true"
      classname="org.mozilla.javascript.drivers.JsDriver"
      maxmemory="${test.vm.mx}"
    >
      <classpath>
        <pathelement location="${xbean.jar}"/>
        <pathelement location="${jsr173.jar}"/>
        <pathelement path="${classes}" />
        <pathelement path="${test.classes}" />
      </classpath>
      <arg value="-p" />
      <arg file="${test.library.dir}" />
      <arg value="-f" />
      <arg value="${test.output}/rhino-test-results.${test.timestamp}.html" />
      <arg value="--timeout" />
      <arg value="${test.timeout}" />
    </java>
  </target>

  <target name="copy-source">
    <mkdir dir="${dist.dir}/testsrc"/>
    <copy todir="${dist.dir}/testsrc">
      <fileset dir="testsrc"
        includes="**/*.java,**/*.properties,**/*.xml,**/*.html,**/*.skip" />
    </copy>
  </target>
</project>