Skip to content
Permalink
Browse files

Work on coverage system

  • Loading branch information
Thrameos committed Mar 22, 2020
1 parent c3118f9 commit 179b3a9d37a6245d270b2bbbe7d6b183864f8f90
Showing with 27 additions and 12 deletions.
  1. +6 −8 .travis.yml
  2. +12 −0 coverage.sh
  3. +9 −4 setupext/build_java.py
@@ -75,16 +75,14 @@ matrix:
- PYTHON=python3
- PIP=pip3
install:
- $PYTHON setup.py --enable-coverage --enable-build-jar build_ext --inplace
- $PYTHON setup.py install
- $PIP install -e .
- $PIP install gcovr pytest-cov jedi
- mvn -f project/coverage package
- $PYTHON setup.py test_java
- mvn -q -f project/coverage package
- $PIP install gcovr pytest-cov jedi
- $PYTHON setup.py --enable-coverage --enable-build-jar build_ext --inplace
script:
- $PYTHON -m pytest -v test/jpypetest --cov=jpype --cov-report=xml:coverage_py.xml --jar="native/org.jpype.jar" --jacoco --checkjni
- gcovr -r . --xml -o coverage.xml -d --exclude-unreachable-branches --exclude-throw-branches
- java -jar project/coverage/org.jacoco.cli-0.8.5-nodeps.jar report jacoco.exec --classfiles build/classes/ --xml coverage_java.xml
- $PYTHON -m pytest -v test/jpypetest --cov=jpype --cov-report=xml:coverage_py.xml --jar="build/classes" --jacoco --checkjni
- gcovr -r . --xml -o coverage.xml --exclude-unreachable-branches --exclude-throw-branches
- java -jar project/coverage/org.jacoco.cli-0.8.5-nodeps.jar report jacoco.exec --classfiles build/classes/ --xml coverage_java.xml --sourcefiles native/java
- bash <(curl -s https://codecov.io/bash) -f coverage.xml -f coverage_py.xml -f coverage_java.xml

install:
@@ -0,0 +1,12 @@
#!/bin/sh

# Script for testing coverage locally
PYTHON=python
PIP="python -m pip"
mvn -q -f project/coverage package
$PYTHON setup.py test_java
$PIP install gcovr pytest-cov jedi
$PYTHON setup.py --enable-coverage --enable-build-jar build_ext --inplace
$PYTHON -m pytest -rsx -v test/jpypetest --cov=jpype --cov-report=xml:coverage_py.xml --jar="build/classes" --jacoco --checkjni
gcovr -r . --html-details -o coverage/coverage.html --exclude-unreachable-branches --exclude-throw-branches
java -jar project/coverage/org.jacoco.cli-0.8.5-nodeps.jar report jacoco.exec --classfiles build/classes/ --html coverage_java --sourcefiles native/java
@@ -11,16 +11,19 @@
import shlex


def compileJava(self):
def compileJava(self, coverage):
target_version = "1.7"
srcs = glob.glob('native/java/**/*.java', recursive=True)
src1 = [i for i in srcs if "JPypeClassLoader" in i]
src2 = [i for i in srcs if not "JPypeClassLoader" in i]
cmd1 = shlex.split('javac -d build/lib -g:none -source %s -target %s' %
(target_version, target_version))
cmd1.extend(src1)
cmd2 = shlex.split('javac -d build/classes -g:none -source %s -target %s -cp build/lib' %
(target_version, target_version))
debug = "-g:none"
if coverage:
debug = "-g:lines,vars,source"
cmd2 = shlex.split('javac -d build/classes %s -source %s -target %s -cp build/lib' %
(debug, target_version, target_version))
cmd2.extend(src2)
os.makedirs("build/lib", exist_ok=True)
os.makedirs("build/classes", exist_ok=True)
@@ -64,9 +67,11 @@ def run(self):
distutils.log.info(
"Jar cache is missing, using --enable-build-jar to recreate it.")

coverage = self.distribution.enable_coverage

# build the jar
try:
compileJava(self)
compileJava(self, coverage)
except subprocess.CalledProcessError as exc:
distutils.log.error(exc.output)
raise DistutilsPlatformError("Error executing {}".format(exc.cmd))

0 comments on commit 179b3a9

Please sign in to comment.
You can’t perform that action at this time.