Skip to content

Commit

Permalink
coverage: Add jacoco and codacy coverage support
Browse files Browse the repository at this point in the history
Signed-off-by: Ce Gao <ce.gao@outlook.com>
  • Loading branch information
gaocegege committed May 8, 2017
1 parent 2f10b78 commit 3e93753
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,12 @@ build.xml

# backup
*.backup

# VS Code
.vscode/

# Java
target/

# Test
test/
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ install:
- ant try

script:
- echo "No test now."
- ant report

after_success:
- curl https://secure.central.sonatype.com/maven2/com/codacy/codacy-coverage-reporter/1.0.13/codacy-coverage-reporter-1.0.13-assembly.jar > codacy-coverage-reporter-assembly.jar
- java -cp codacy-coverage-reporter-assembly.jar com.codacy.CodacyCoverageReporter -l Java -r test/site/jacoco/report.xml
71 changes: 70 additions & 1 deletion build.xml.template
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
<?xml version="1.0"?>
<project name="processing.r" default="install" basedir="./">
<project name="Processing.R" default="install" basedir="." xmlns:jacoco="antlib:org.jacoco.ant">
<property name="mode.name" value="RLangMode" />

<!-- folder to install modes in (probably a folder called "modes" inside your sketchbook folder) -->
<property name="processing.modes" location="@@modes@@" />

<!-- path to your processing executable. -->
<property name="processing.executable" location="@@executable@@" />
<property name="processing" value="@@processing@@" />

<!-- location of processing jars (core.jar, pde.jar, ..) -->
<property name="processing.classes.core" location="@@core@@" />
<property name="processing.classes.pde" location="@@pde@@" />
<property name="renjin" value="@@renjin@@" />
<property name="java.target.version" value="1.8" />

<!-- Folder -->
<property name="try" value="try" />
<property name="lib" value="lib" />
<property name="src" value="src" />
<property name="build" value="build" />
<property name="bin" value="bin" />
<property name="dist" value="dist" />

<!-- Test -->
<property name="test.build.dir" value="test" />
<property name="test.src.dir" value="src" />
<property name="result.dir" location="target"/>
<property name="result.classes.dir" location="${test.build.dir}"/>
<property name="result.report.dir" location="${test.build.dir}/site/jacoco"/>
<property name="result.exec.file" location="${test.build.dir}/jacoco.exec"/>

<path id="library-classpath">
<fileset dir="${processing.classes.core}">
<include name="*.jar" />
Expand All @@ -29,6 +42,13 @@
<include name="*.jar" />
</fileset>
</path>

<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath>
<path refid="library-classpath" />
</classpath>
</taskdef>

<target name="try" depends="build">
<propertyfile file="build.number" />
<!-- create the build.number file if it doesn't exist -->
Expand Down Expand Up @@ -102,4 +122,53 @@
<target name="run" depends="install">
<exec executable="${processing.executable}" spawn="false" />
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - -
TEST
- - - - - - - - - - - - - - - - - - - - - - - -->
<target name="test-compile" depends="build">
<mkdir dir="${test.build.dir}"/>
<javac srcdir="${test.src.dir}" destdir="${test.build.dir}" includeantruntime="false">
<classpath>
<path refid="library-classpath" />
</classpath>
</javac>
</target>
<target name="test" depends="test-compile">
<jacoco:coverage destfile="${result.exec.file}">
<junit printsummary="on" haltonfailure="yes" fork="true">
<classpath>
<path refid="library-classpath" />
<pathelement location="${build}"/>
</classpath>
<formatter type="brief" usefile="false" />
<batchtest>
<fileset dir="${test.src.dir}" includes="**/*Test.java" />
</batchtest>
</junit>
</jacoco:coverage>
</target>
<target name="report" depends="test">
<!-- Step 3: Create coverage report -->
<jacoco:report>
<!--
This task needs the collected execution data and ...
-->
<executiondata>
<file file="${result.exec.file}"/>
</executiondata>
<!-- the class files and optional source files ... -->
<structure name="JaCoCo Ant Example">
<classfiles>
<fileset dir="${result.classes.dir}"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${test.src.dir}"/>
</sourcefiles>
</structure>
<!-- to produce reports in different formats. -->
<html destdir="${result.report.dir}"/>
<csv destfile="${result.report.dir}/report.csv"/>
<xml destfile="${result.report.dir}/report.xml"/>
</jacoco:report>
</target>
</project>
Binary file added lib/jacocoagent.jar
Binary file not shown.
Binary file added lib/jacocoant.jar
Binary file not shown.
Binary file added lib/junit-4.12.jar
Binary file not shown.
Binary file added lib/org.hamcrest.core_1.3.0.v201303031735.jar
Binary file not shown.
Binary file added lib/org.jacoco.agent-0.7.10.201705050707.jar
Binary file not shown.
Binary file added lib/org.jacoco.ant-0.7.10.201705050707.jar
Binary file not shown.
Binary file added lib/org.jacoco.core-0.7.10.201705050707.jar
Binary file not shown.
Binary file added lib/org.jacoco.report-0.7.10.201705050707.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
[![Gitter](https://badges.gitter.im/gaocegege/Processing.R.svg)](https://gitter.im/gaocegege/Processing.R?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Build status](https://ci.appveyor.com/api/projects/status/9lq6psaw9c18ins8/branch/master?svg=true)](https://ci.appveyor.com/project/gaocegege/processing-r/branch/master)
[![GitHub release](https://img.shields.io/github/release/gaocegege/Processing.R.svg)](https://github.com/gaocegege/Processing.R/releases)
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/33ebc49f6f764fffb7ea7bf617edf902)](https://www.codacy.com/app/gaocegege/Processing-R?utm_source=github.com&utm_medium=referral&utm_content=gaocegege/Processing.R&utm_campaign=Badge_Coverage)
-->

<p align="center">
Expand All @@ -21,6 +22,7 @@
<a href="https://quay.io/repository/gaocegege/processing.r"><img src="https://img.shields.io/badge/docker-supported-blue.svg" alt=""></a>
<a href="https://quay.io/repository/gaocegege/processing.r"><img src="https://quay.io/repository/gaocegege/processing.r/status" alt="Docker Repository on Quay" title="Docker Repository on Quay"></a>
<a href="https://www.codacy.com/app/gaocegege/Processing-R?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=gaocegege/Processing.R&amp;utm_campaign=Badge_Grade"><img src="https://api.codacy.com/project/badge/Grade/33ebc49f6f764fffb7ea7bf617edf902" alt="Codacy Badge"></a>
<a href="https://www.codacy.com/app/gaocegege/Processing-R?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=gaocegege/Processing.R&amp;utm_campaign=Badge_Coverage"><img src="https://api.codacy.com/project/badge/Coverage/33ebc49f6f764fffb7ea7bf617edf902" alt="Codacy Badge"></a>
<a href="https://github.com/gaocegege/Processing.R/releases"><img src="https://img.shields.io/github/downloads/gaocegege/Processing.R/total.svg" alt="GitHub Download"></a>
<a href="https://github.com/gaocegege/Processing.R/releases"><img src="https://img.shields.io/github/release/gaocegege/Processing.R.svg" alt="GitHub Release"></a>
<a href="https://gitter.im/gaocegege/Processing.R?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge"><img src="https://badges.gitter.im/gaocegege/Processing.R.svg" alt="Gitter"></a>
Expand Down
2 changes: 1 addition & 1 deletion src/rprocessing/util/Printer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

public interface Printer {
void print(Object o);
}
}

0 comments on commit 3e93753

Please sign in to comment.