aboutsummaryrefslogtreecommitdiffstats
path: root/org.jacoco.ant.test/src/org/jacoco/ant/MergeTaskTest.xml
blob: dcaecc9b3356828431ead91b31310c98b9a3b6f7 (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
73
74
<?xml version="1.0" encoding="UTF-8"?>

<!-- 
   Copyright (c) 2009, 2012 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
      
   $Id: $
-->

<project name="JaCoCo Merge 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" />
	</target>

	<target name="tearDown">
		<delete dir="${temp.dir}" quiet="false" failonerror="true"/>
	</target>
	
	<target name="testMergeNoDestination">
		<au:expectfailure expectedMessage="Destination file must be supplied">
			<jacoco:merge/>
		</au:expectfailure>
	</target>
	
	<target name="testMergeToDirectory">
		<au:expectfailure expectedMessage="Unable to write merged file ${temp.dir}">
			<jacoco:merge destfile="${temp.dir}"/>
		</au:expectfailure>
	</target>
	
	<target name="testMergeEmptySet">
		<jacoco:merge destfile="${exec.file}"/>
		
		<au:assertFileExists file="${exec.file}"/>
	</target>
	
	<target name="testMergeMultipleFiles">
		<jacoco:merge destfile="${exec.file}">
			<fileset dir="${basedir}/data" includes="*.exec"/>
		</jacoco:merge>
		
		<property name="sample1.file" location="${basedir}/data/sample1.exec"/>
		<property name="sample2.file" location="${basedir}/data/sample2.exec"/>
		<au:assertLogContains text="Loading execution data file ${sample1.file}"/>
		<au:assertLogContains text="Loading execution data file ${sample2.file}"/>
		<au:assertFileExists file="${exec.file}"/>
	</target>
	
	<target name="testMergeBadFiles">
		<property name="bad.file" location="${basedir}/data/sample.bad"/>
		<au:expectfailure expectedMessage="Unable to read ${bad.file}">
		<jacoco:merge destfile="${exec.file}">
			<file file="${basedir}/data/sample.bad"/>
		</jacoco:merge>
		</au:expectfailure>
	</target>
	
	<target name="testMergeDirectory">
		<jacoco:merge destfile="${exec.file}">
			<dirset dir="${basedir}/data"/>
		</jacoco:merge>

		<au:assertFileExists file="${exec.file}"/>
	</target>
</project>