aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-06-17 04:27:03 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2015-06-17 18:53:08 +0200
commit8e60ccb650ba4af516687558fe365540a92a1630 (patch)
tree02ae57eb3c56f4eeb1aec26fca3360d47fae93d9
parent0d61221c5f85d0a08025a5b87fa8dfb11b961e9e (diff)
downloadopen-keychain-8e60ccb650ba4af516687558fe365540a92a1630.tar.gz
open-keychain-8e60ccb650ba4af516687558fe365540a92a1630.tar.bz2
open-keychain-8e60ccb650ba4af516687558fe365540a92a1630.zip
workaround for coverage bug (for now!)
see android bug report https://code.google.com/p/android/issues/detail?id=170607
-rw-r--r--OpenKeychain/build.gradle7
-rw-r--r--OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/JacocoWorkaroundJUnitRunner.java29
2 files changed, 34 insertions, 2 deletions
diff --git a/OpenKeychain/build.gradle b/OpenKeychain/build.gradle
index f85678b67..491926a4e 100644
--- a/OpenKeychain/build.gradle
+++ b/OpenKeychain/build.gradle
@@ -114,7 +114,7 @@ android {
versionCode 32300
versionName "3.2.3"
applicationId "org.sufficientlysecure.keychain"
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ testInstrumentationRunner "org.sufficientlysecure.keychain.JacocoWorkaroundJUnitRunner"
}
compileOptions {
@@ -217,7 +217,10 @@ task jacocoTestReport(type:JacocoReport) {
"${buildDir}/generated/source/buildConfig/debug",
"${buildDir}/generated/source/r/debug"
])
- executionData = files("${buildDir}/jacoco/testDebug.exec")
+ executionData = files([
+ "${buildDir}/jacoco/testDebug.exec",
+ "${buildDir}/outputs/code-coverage/connected/coverage.ec"
+ ])
reports {
xml.enabled = true
diff --git a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/JacocoWorkaroundJUnitRunner.java b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/JacocoWorkaroundJUnitRunner.java
new file mode 100644
index 000000000..b310ed5b8
--- /dev/null
+++ b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/JacocoWorkaroundJUnitRunner.java
@@ -0,0 +1,29 @@
+package org.sufficientlysecure.keychain;
+
+
+import java.lang.reflect.Method;
+
+import android.os.Bundle;
+import android.support.test.runner.AndroidJUnitRunner;
+
+
+public class JacocoWorkaroundJUnitRunner extends AndroidJUnitRunner {
+ static {
+ System.setProperty("jacoco-agent.destfile", "/data/data/"
+ + BuildConfig.APPLICATION_ID + "/coverage.ec");
+ }
+
+ @Override
+ public void finish(int resultCode, Bundle results) {
+ try {
+ Class rt = Class.forName("org.jacoco.agent.rt.RT");
+ Method getAgent = rt.getMethod("getAgent");
+ Method dump = getAgent.getReturnType().getMethod("dump", boolean.class);
+ Object agent = getAgent.invoke(null);
+ dump.invoke(agent, false);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ super.finish(resultCode, results);
+ }
+} \ No newline at end of file