aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.ant.test/src/org/jacoco/ant/DumpTaskWithServerTest.xml
blob: 6a3b9ddf9a167a5afc2f79487c2ea0ea26962e94 (plain)
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
<?xml version="1.0" encoding="UTF-8"?>

<!-- 
   Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors
   All rights reserved. This program and the accompanying materials
   are made available under the terms of the Eclipse Public License v1.0
   which accompanies this distribution, and is available at
   http://www.eclipse.org/legal/epl-v10.html
  
   Contributors:
      Brock Janiczak - initial API and implementation
-->

<project name="JaCoCo Dump Task Tests" xmlns:au="antlib:org.apache.ant.antunit" xmlns:jacoco="antlib:org.jacoco.ant">

	<target name="setUp">
		<tempfile property="temp.dir" prefix="jacocoTest" destdir="${java.io.tmpdir}" />
		<mkdir dir="${temp.dir}"/>
		<property name="exec.file" location="${temp.dir}/exec.file" />
		<property name="term.file" location="${temp.dir}/term.file" />
		
		<jacoco:coverage output="tcpserver" port="6300">
			<java classname="org.jacoco.ant.TestTarget" spawn="true" fork="true" maxmemory="16m">
				<classpath path="${org.jacoco.ant.dumpTaskWithServerTest.classes.dir}"/>
				<jvmarg value="-client"/>
				<arg value="${term.file}"/>
			</java>
		</jacoco:coverage>
		
		<waitfor maxwait="1" maxwaitunit="second" checkevery="10" checkeveryunit="millisecond">
			<socket server="localhost" port="6300"/>
		</waitfor>
	</target>

	<target name="tearDown">
		<touch file="${term.file}"/>
		<waitfor maxwait="5" maxwaitunit="second" checkevery="10" checkeveryunit="millisecond">
			<not>
				<socket server="localhost" port="6300"/>
			</not>
		</waitfor>
		<delete dir="${temp.dir}" quiet="false" failonerror="true"/>
	</target>
	
	
	<target name="testDump">
		<jacoco:dump dump="true" destfile="${exec.file}"/>
		
		<au:assertFileExists file="${exec.file}"/>
		<au:assertLogContains text="Dumping execution data to ${exec.file}"/>
	</target>
	
	<target name="testNoDumpOrReset">
		<jacoco:dump dump="false" reset="false"/>

		<au:assertLogDoesntContain text="Dumping execution data to"/>
	</target>

	<target name="testResetOnly">
		<jacoco:dump dump="false" reset="true"/>
		
		<au:assertLogDoesntContain text="Dumping execution data to"/>
	</target>
	
	<target name="testNoDumpWithFileSet">
		<jacoco:dump dump="false" destfile="${exec.file}"/>
		
		<au:assertLogDoesntContain text="Dumping execution data to"/>
		<au:assertFileDoesntExist file="${exec.file}"/>
	</target>
	
</project>