diff --git a/AnkiDroid/build.gradle b/AnkiDroid/build.gradle index a4ae27034397..d23789c0783d 100644 --- a/AnkiDroid/build.gradle +++ b/AnkiDroid/build.gradle @@ -207,6 +207,24 @@ task installGitHook(type: Copy) { } tasks.getByPath(':AnkiDroid:preBuild').dependsOn installGitHook +// Issue 11078 - some emulators run, but run zero tests, and still report success +task assertNonzeroAndroidTests() { + doLast { + File folder = file("./build/outputs/androidTest-results/connected/flavors/play") + File[] listOfFiles = folder.listFiles({d, f-> f ==~ /.*.xml/ } as FilenameFilter) + for (File file : listOfFiles) { + String[] matches = file.readLines().findAll { it.contains('testsuite tests="0"')} + if (matches.length != 0) { + throw new GradleScriptException("androidTest executed 0 tests for " + file.name + " - Probably a bug with the emulator. Try another image.", null) + } + + } + } +} +afterEvaluate { + tasks.getByPath(':AnkiDroid:connectedPlayDebugAndroidTest').finalizedBy(assertNonzeroAndroidTests) +} + apply from: "./robolectricDownloader.gradle" apply from: "./jacoco.gradle" apply from: "../lint.gradle"