Skip to content

Commit 647f595

Browse files
committed
Debug logs
1 parent 890c1f6 commit 647f595

File tree

1 file changed

+65
-6
lines changed

1 file changed

+65
-6
lines changed

.github/workflows/sonarqube.yml

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,23 +194,60 @@ jobs:
194194
./gradlew assembleDebugAndroidTest
195195
196196
# First, let's determine the correct test package name
197+
echo "\n[DEBUG] Listing all available instrumentation packages:"
198+
adb shell pm list instrumentation
199+
197200
TEST_PACKAGE=$(adb shell pm list instrumentation | grep split | cut -d' ' -f1 | cut -d: -f2)
198-
echo "Found test instrumentation package: $TEST_PACKAGE"
201+
echo "\n[DEBUG] Found test instrumentation package: $TEST_PACKAGE"
202+
203+
# Check if the test APK is installed properly
204+
echo "\n[DEBUG] Checking installed packages:"
205+
adb shell pm list packages | grep split
206+
207+
# Verify test class exists
208+
echo "\n[DEBUG] Checking if test class exists:"
209+
./gradlew -q listTestClasses | grep DatabaseInitializationTest || echo "Test class not found in Gradle test classes"
199210
200211
# Run only a single test class with coverage explicitly enabled
212+
echo "\n[DEBUG] Running instrumentation with explicit coverage flag:"
201213
adb shell am instrument -w -e coverage true -e class tests.database.DatabaseInitializationTest $TEST_PACKAGE
202214
TEST_RESULT=$?
203215
if [ $TEST_RESULT -ne 0 ]; then
204216
echo "Some instrumented tests failed, but continuing to check for coverage data..."
217+
else
218+
echo "\n[DEBUG] Instrumentation completed successfully"
205219
fi
206220
207221
# Create directory for coverage files
208222
mkdir -p build/outputs/code_coverage/debugAndroidTest/connected/
209223
210224
# Try to find and pull coverage files from various possible locations
211-
echo "Searching for coverage files..."
225+
echo "\n[DEBUG] Searching for coverage files..."
226+
227+
# Check if coverage is enabled in the app manifest
228+
echo "\n[DEBUG] Checking test AndroidManifest.xml for coverage settings:"
229+
adb shell pm dump $TEST_PACKAGE | grep -i coverage
212230
213-
# Check app-specific data directory
231+
# Check for files in external storage
232+
echo "\n[DEBUG] Checking external storage for coverage files:"
233+
adb shell ls -la /sdcard/ | grep -i coverage || echo "No coverage files found in /sdcard/"
234+
235+
# Check app-specific data directory - try both package names
236+
echo "\n[DEBUG] Checking app-specific data directory for coverage files:"
237+
APP_PACKAGE=$(adb shell pm list packages | grep split | cut -d: -f2 | head -1)
238+
echo "\n[DEBUG] App package name: $APP_PACKAGE"
239+
240+
# Try with the detected app package
241+
echo "\n[DEBUG] Searching in /data/data/$APP_PACKAGE/:"
242+
adb shell run-as $APP_PACKAGE find /data/data/$APP_PACKAGE -name "*.ec" | while read -r file; do
243+
echo "Found coverage file: $file"
244+
filename=$(basename "$file")
245+
adb shell run-as $APP_PACKAGE cat "$file" > "build/outputs/code_coverage/debugAndroidTest/connected/$filename"
246+
echo "Pulled coverage file to build/outputs/code_coverage/debugAndroidTest/connected/$filename"
247+
done
248+
249+
# Also try with the hardcoded package name as fallback
250+
echo "\n[DEBUG] Searching in /data/data/io.split.android.android_client/:"
214251
adb shell run-as io.split.android.android_client find /data/data/io.split.android.android_client -name "*.ec" | while read -r file; do
215252
echo "Found coverage file: $file"
216253
filename=$(basename "$file")
@@ -219,16 +256,38 @@ jobs:
219256
done
220257
221258
# Also check sdcard location
259+
echo "\n[DEBUG] Checking /sdcard/ location:"
222260
adb pull /sdcard/coverage.ec build/outputs/code_coverage/debugAndroidTest/connected/ || echo "No coverage file at /sdcard/coverage.ec"
223261
262+
# Try alternative locations
263+
echo "\n[DEBUG] Checking alternative locations for coverage files:"
264+
adb pull /data/local/tmp/coverage.ec build/outputs/code_coverage/debugAndroidTest/connected/ || echo "No coverage file at /data/local/tmp/coverage.ec"
265+
224266
# List all coverage files to verify
267+
echo "\n[DEBUG] Listing all found coverage files:"
225268
find build -name "*.ec" -o -name "*.exec"
226269
227-
# Run the JaCoCo report task
228-
./gradlew jacocoAndroidTestReport
270+
# Run the JaCoCo report task with debug info
271+
echo "\n[DEBUG] Running JaCoCo Android test report task with debug info:"
272+
./gradlew jacocoAndroidTestReport --debug > jacoco_debug.log
229273
REPORT_RESULT=$?
274+
275+
# Save the important parts of the debug log
276+
echo "\n[DEBUG] Extracting coverage-related info from debug log:"
277+
grep -A 10 -B 2 "JaCoCo" jacoco_debug.log > jacoco_important.log || echo "No JaCoCo info found in debug log"
278+
grep -A 5 -B 2 "coverage" jacoco_debug.log >> jacoco_important.log || echo "No coverage info found in debug log"
279+
grep -A 3 -B 1 "exec" jacoco_debug.log >> jacoco_important.log || echo "No exec info found in debug log"
280+
grep -A 3 -B 1 "ec" jacoco_debug.log >> jacoco_important.log || echo "No .ec info found in debug log"
281+
282+
echo "\n[DEBUG] Important JaCoCo debug info:"
283+
cat jacoco_important.log
284+
230285
if [ $REPORT_RESULT -ne 0 ]; then
231-
echo "Failed to generate Android test coverage report, but continuing..."
286+
echo "\n[DEBUG] Failed to generate Android test coverage report, but continuing..."
287+
echo "\n[DEBUG] Last 20 lines of debug log:"
288+
tail -20 jacoco_debug.log
289+
else
290+
echo "\n[DEBUG] JaCoCo Android test report generated successfully"
232291
fi
233292
234293
# Check if the Android test report was generated with content

0 commit comments

Comments
 (0)