Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .github/workflows/scripts-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ jobs:
target: google_apis
script: |
./scripts/run-android-instrumentation-tests.sh "${{ steps.build-android-app.outputs.gradle_project_dir }}"
./scripts/generate-android-coverage-report.sh "${{ steps.build-android-app.outputs.gradle_project_dir }}"
- name: Upload emulator screenshot
if: always() # still collect it if tests fail
uses: actions/upload-artifact@v4
Expand All @@ -110,12 +109,3 @@ jobs:
if-no-files-found: warn
retention-days: 14
compression-level: 6
- name: Upload Android Jacoco coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: android-jacoco-coverage
path: artifacts/android-coverage-report
if-no-files-found: warn
retention-days: 14
compression-level: 6
86 changes: 0 additions & 86 deletions scripts/android/lib/PatchGradleFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ private static boolean patchAppBuildGradle(Path path, int compileSdk, int target
content = r.content();
changed |= r.changed();

r = ensureJacocoConfiguration(content);
content = r.content();
changed |= r.changed();

if (changed) {
Files.writeString(path, ensureTrailingNewline(content), StandardCharsets.UTF_8);
}
Expand Down Expand Up @@ -251,88 +247,6 @@ private static Result ensureTestDependencies(String content) {
return new Result(content + block, true);
}

private static Result ensureJacocoConfiguration(String content) {
if (content.contains("jacocoAndroidReport")) {
return new Result(content, false);
}

String jacocoBlock = """
apply plugin: 'jacoco'

android {
buildTypes {
debug {
testCoverageEnabled true
}
}
}

jacoco {
toolVersion = "0.8.11"
}

tasks.register("jacocoAndroidReport", JacocoReport) {
group = "verification"
description = "Generates Jacoco coverage report for the debug variant"
outputs.upToDateWhen { false }

reports {
xml.required = true
html.required = true
html.outputLocation = layout.buildDirectory.dir("reports/jacoco/jacocoAndroidReport/html")
}

def coverageFiles = fileTree(dir: "$buildDir", includes: [
"outputs/code_coverage/**/*coverage.ec",
"jacoco/*.exec",
"outputs/unit_test_code_coverage/**/*coverage.ec",
"**/*.ec",
"**/*.exec"
])

def excludes = [
'**/R.class',
'**/R$*.class',
'**/BuildConfig.*',
'**/Manifest*.*',
'**/*Test*.*',
'**/androidx/**/*',
'**/com/google/**/*'
]

def javaClasses = fileTree(dir: "$buildDir/intermediates/javac/debug/classes", exclude: excludes)
def kotlinClasses = fileTree(dir: "$buildDir/tmp/kotlin-classes/debug", exclude: excludes)
def aarMainJar = file("$buildDir/intermediates/aar_main_jar/debug/classes.jar")
def aarTrees = aarMainJar.exists() ? [zipTree(aarMainJar)] : []
def runtimeJars = configurations.debugRuntimeClasspath.filter { it.name.endsWith('.jar') }.collect { zipTree(it) }

classDirectories.setFrom(files(javaClasses, kotlinClasses, aarTrees, runtimeJars).asFileTree.matching {
include 'com/codename1/impl/android/**'
})

sourceDirectories.setFrom(files("src/main/java"))

executionData.setFrom(coverageFiles)

doFirst {
def existing = coverageFiles.files.findAll { it.exists() }
if (existing.isEmpty()) {
throw new GradleException("No Jacoco coverage data found. Ensure connectedDebugAndroidTest runs with coverage enabled.")
}
logger.lifecycle("Jacoco coverage inputs: ${existing}")
}
}

afterEvaluate {
tasks.matching { it.name == "connectedDebugAndroidTest" }.configureEach {
finalizedBy(tasks.named("jacocoAndroidReport"))
}
}
""".stripTrailing();

return new Result(ensureTrailingNewline(content) + "\n" + jacocoBlock + "\n", true);
}

private static String ensureTrailingNewline(String content) {
return content.endsWith("\n") ? content : content + "\n";
}
Expand Down
3 changes: 1 addition & 2 deletions scripts/android/tests/Cn1ssChunkTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private static void runTests(String[] args) throws IOException {
}
Path path = Path.of(args[0]);
List<String> names = new ArrayList<>();
for (Chunk chunk : iterateChunks(path, Optional.empty(), Optional.of(DEFAULT_CHANNEL))) {
for (Chunk chunk : iterateChunks(path, Optional.empty(), Optional.empty())) {
if (!names.contains(chunk.testName)) {
names.add(chunk.testName);
}
Expand All @@ -139,7 +139,6 @@ private static void runTests(String[] args) throws IOException {
System.out.println(name);
}
}

private static Iterable<Chunk> iterateChunks(Path path, Optional<String> testFilter, Optional<String> channelFilter) throws IOException {
String text = Files.readString(path, StandardCharsets.UTF_8);
List<Chunk> result = new ArrayList<>();
Expand Down
Loading
Loading