-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathbuild-junit.xml
154 lines (138 loc) · 7.1 KB
/
build-junit.xml
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
<?xml version="1.0" encoding="UTF-8" ?>
<!--
This file is part of SoSy-Lab Java-Project Template,
a collection of common files and build definitions for Java projects:
https://gitlab.com/sosy-lab/software/java-project-template
SPDX-FileCopyrightText: 2018-2020 Dirk Beyer <https://www.sosy-lab.org>
SPDX-License-Identifier: Apache-2.0
-->
<!-- vim: set tabstop=8 shiftwidth=4 expandtab filetype=ant : -->
<project name="junit" basedir="."
xmlns:jacoco="antlib:org.jacoco.ant">
<!-- Targets for running JUnit. -->
<!-- DO NOT EDIT LOCALLY!
Keep this file synchronized with
https://gitlab.com/sosy-lab/software/java-project-template
-->
<!-- Can be overridden from including file. -->
<property name="junit.dir" value="junit"/>
<!-- Define property that contains the Ant version for getting the matching ant-junit version. -->
<antversion property="ant.version.exact"/>
<!-- Load the JUnit plugin for Ant if it's not installed. -->
<condition property="ant.junit.available">
<typefound name="junit"/>
</condition>
<target name="load-junit" depends="resolve-dependencies" unless="ant.junit.available">
<taskdef name="junit"
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"
classpath="${ivy.jar.dir}/ant-junit.jar:${ivy.jar.dir}/ant-junit4.jar"/>
<taskdef name="junitreport"
classname="org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator"
classpath="${ivy.jar.dir}/ant-junit.jar:${ivy.jar.dir}/ant-junit4.jar"/>
</target>
<target name="init-unit-tests">
<!-- Provide default classpath if none is specified. -->
<path id="classpath.junit">
<path refid="classpath"/>
</path>
<delete dir="${junit.dir}"/>
<mkdir dir="${junit.dir}"/>
</target>
<macrodef name="run-junit-tests">
<sequential>
<junit fork="true" printSummary="true" showOutput="false" failureproperty="junit.failed" timeout="600000">
<assertions><enable/></assertions>
<formatter type="xml"/>
<classpath refid="classpath.junit"/>
<sysproperty key="java.awt.headless" value="true" />
<batchtest fork="true" todir="${junit.dir}">
<fileset dir="${class.dir}">
<patternset refid="test.sources"/>
</fileset>
</batchtest>
</junit>
<junitreport todir="${junit.dir}">
<fileset dir="${junit.dir}" includes="TEST-*.xml"/>
<report format="noframes"/>
</junitreport>
<move file="junit-noframes.html" tofile="JUnit.html"/>
<fail if="junit.failed" message="JUnit tests failed, look at JUnit.html"/>
</sequential>
</macrodef>
<target name="unit-tests-quick" depends="build, load-junit, init-unit-tests"
description="Run a minimal set of JUnit tests that are considered quick">
<!-- A simpler way for specifying quick tests would be an annotation on class or method level.
JUnit 5 might bring such features. However, we still depend on JUnit 4. -->
<patternset id="test.sources">
<include name="**/solvers/bitwuzla/BitwuzlaNativeApiTest.*"/>
<include name="**/solvers/boolector/BoolectorNativeApiTest.*"/>
<include name="**/solvers/cvc4/CVC4NativeAPITest.*"/>
<include name="**/solvers/cvc5/CVC5NativeAPITest.*"/>
<include name="**/solvers/mathsat5/Mathsat5AbstractNativeApiTest.*"/>
<include name="**/solvers/mathsat5/Mathsat5NativeApiTest.*"/>
<include name="**/solvers/mathsat5/Mathsat5OptimizationNativeApiTest.*"/>
<include name="**/solvers/opensmt/OpenSmtNativeAPITest.*"/>
<include name="**/solvers/yices2/Yices2NativeApiTest.*"/>
<include name="**/test/FloatingPointNumberTest.*"/>
<include name="**/test/FormulaManagerTest.*"/>
<include name="**/test/NumeralFormulaManagerTest.*"/>
<include name="**/test/ProverEnvironmentTest.*"/>
<include name="**/test/RationalFormulaManagerTest.*"/>
<include name="**/test/SolverContextFactoryTest.*"/>
<include name="**/test/SolverContextTest.*"/>
</patternset>
<run-junit-tests/>
</target>
<target name="unit-tests" depends="build, load-junit, init-unit-tests"
description="Run all JUnit tests">
<patternset id="test.sources">
<include name="**/*Test.*"/>
<exclude name="**/*$*Test.*"/>
</patternset>
<run-junit-tests/>
</target>
<target name="load-jacoco" depends="resolve-dependencies">
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath><fileset dir="${ivy.jar.dir}" includes="org.jacoco.*.jar asm*.jar"/></classpath>
</taskdef>
</target>
<target name="unit-tests-coverage" depends="build, load-junit, load-jacoco, init-unit-tests" description="Run all JUnit tests with coverage report">
<jacoco:coverage destfile="${junit.dir}/jacoco.exec" excludes="**/*Test*:**/Dummy*">
<junit fork="true" printSummary="true" showOutput="false" failureproperty="junit.failed" timeout="600000">
<assertions><enable/></assertions>
<formatter type="xml"/>
<classpath refid="classpath.junit"/>
<sysproperty key="java.awt.headless" value="true" />
<batchtest fork="true" todir="${junit.dir}">
<fileset dir="${class.dir}">
<include name="**/*Test.*"/>
<exclude name="**/*$*Test.*"/>
</fileset>
</batchtest>
</junit>
</jacoco:coverage>
<jacoco:report>
<executiondata><file file="${junit.dir}/jacoco.exec"/></executiondata>
<structure name="${ant.project.name}">
<classfiles><fileset dir="${class.dir}" excludes="**/*Test*,**/Dummy*/"/></classfiles>
<sourcefiles encoding="UTF-8"><fileset dir="${source.dir}" excludes="**/*Test*,**/Dummy*/"/></sourcefiles>
</structure>
<html destdir="JUnit-coverage"/>
<xml destfile="${junit.dir}/coverage.xml"/>
<csv destfile="${junit.dir}/coverage.csv"/>
</jacoco:report>
<junitreport todir="${junit.dir}">
<fileset dir="${junit.dir}" includes="TEST-*.xml"/>
<report format="noframes"/>
</junitreport>
<exec executable="awk" failifexecutionfails="false" failonerror="false">
<arg value="-F,"/>
<arg value='-v'/>
<arg value='OFS='/>
<arg value='{ instructions += $4 + $5; covered += $5 } END { print covered, " / ", instructions, " instructions covered"; print 100*covered/instructions, "% covered" }'/>
<arg value="${junit.dir}/coverage.csv"/>
</exec>
<move file="junit-noframes.html" tofile="JUnit.html"/>
<fail if="junit.failed" message="JUnit tests failed, look at JUnit.html"/>
</target>
</project>