Start including logs in test results
This commit is contained in:
parent
b50797fc2d
commit
8711bbeda3
4 changed files with 28 additions and 18 deletions
10
.github/workflows/test.yml
vendored
10
.github/workflows/test.yml
vendored
|
|
@ -32,7 +32,7 @@ jobs:
|
||||||
path: |
|
path: |
|
||||||
~/.android/avd/*
|
~/.android/avd/*
|
||||||
~/.android/adb*
|
~/.android/adb*
|
||||||
key: aosp-${{ matrix.emulator_type }}-${{ matrix.android_target }}-${{ runner.os }}
|
key: avd-${{ matrix.emulator_type }}-${{ matrix.android_target }}
|
||||||
|
|
||||||
- name: Build Release APK
|
- name: Build Release APK
|
||||||
run: ./gradlew :app:assembleRelease
|
run: ./gradlew :app:assembleRelease
|
||||||
|
|
@ -99,14 +99,14 @@ jobs:
|
||||||
medium_test_exit_code=0
|
medium_test_exit_code=0
|
||||||
./gradlew --stacktrace -Pinstrumented_test_size=medium :app:connectedAndroidTest || medium_test_exit_code=$?
|
./gradlew --stacktrace -Pinstrumented_test_size=medium :app:connectedAndroidTest || medium_test_exit_code=$?
|
||||||
|
|
||||||
adb pull /sdcard/seedvault_test_videos
|
adb pull /sdcard/seedvault_test_results
|
||||||
|
|
||||||
if [ $large_test_exit_code -ne 0 ]; then echo 'Gradle test failed.'; exit 0; fi
|
if [ $large_test_exit_code -ne 0 ]; then echo 'Gradle test failed.'; exit 0; fi
|
||||||
if [ $medium_test_exit_code -ne 0 ]; then echo 'Gradle test failed.'; exit 0; fi
|
if [ $medium_test_exit_code -ne 0 ]; then echo 'Gradle test failed.'; exit 0; fi
|
||||||
|
|
||||||
- name: Upload screenshots and videos
|
- name: Upload test results
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: seedvault_test_videos
|
name: ${{ matrix.emulator_type }}-${{ matrix.android_target }}-results
|
||||||
path: seedvault_test_videos/**/*.mp4
|
path: seedvault_test_results/**/*
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ tasks.register('provisionEmulator', Exec) {
|
||||||
doFirst {
|
doFirst {
|
||||||
commandLine "${project.projectDir}/development/scripts/provision_emulator.sh",
|
commandLine "${project.projectDir}/development/scripts/provision_emulator.sh",
|
||||||
"seedvault",
|
"seedvault",
|
||||||
"system-images;android-33;google_apis;x86_64"
|
"system-images;android-33;default;x86_64"
|
||||||
|
|
||||||
environment "ANDROID_HOME", android.sdkDirectory.absolutePath
|
environment "ANDROID_HOME", android.sdkDirectory.absolutePath
|
||||||
environment "JAVA_HOME", System.properties['java.home']
|
environment "JAVA_HOME", System.properties['java.home']
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ internal interface LargeTestBase : KoinComponent {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val TEST_STORAGE_FOLDER = "seedvault_test"
|
private const val TEST_STORAGE_FOLDER = "seedvault_test"
|
||||||
private const val TEST_VIDEO_FOLDER = "seedvault_test_videos"
|
private const val TEST_VIDEO_FOLDER = "seedvault_test_results"
|
||||||
}
|
}
|
||||||
|
|
||||||
val externalStorageDir: String get() = Environment.getExternalStorageDirectory().absolutePath
|
val externalStorageDir: String get() = Environment.getExternalStorageDirectory().absolutePath
|
||||||
|
|
@ -106,19 +106,23 @@ internal interface LargeTestBase : KoinComponent {
|
||||||
uiAutomation.executeShellCommand(command).close()
|
uiAutomation.executeShellCommand(command).close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun testResultFilename(testName: String): String {
|
||||||
|
val simpleDateFormat = SimpleDateFormat("yyyyMMdd_hhmmss")
|
||||||
|
val timeStamp = simpleDateFormat.format(Calendar.getInstance().time)
|
||||||
|
return "${timeStamp}_${testName.replace(" ", "_")}"
|
||||||
|
}
|
||||||
|
|
||||||
@OptIn(DelicateCoroutinesApi::class)
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
suspend fun startScreenRecord(
|
suspend fun startRecordingTest(
|
||||||
keepRecordingScreen: AtomicBoolean,
|
keepRecordingScreen: AtomicBoolean,
|
||||||
testName: String,
|
testName: String,
|
||||||
) {
|
) {
|
||||||
val simpleDateFormat = SimpleDateFormat("yyyyMMdd_hhmmss")
|
|
||||||
val timeStamp = simpleDateFormat.format(Calendar.getInstance().time)
|
|
||||||
val fileName = "${timeStamp}_${testName.replace(" ", "_")}"
|
|
||||||
|
|
||||||
val folder = testVideoPath
|
val folder = testVideoPath
|
||||||
runCommand("mkdir -p $folder")
|
runCommand("mkdir -p $folder")
|
||||||
|
|
||||||
|
val fileName = testResultFilename(testName)
|
||||||
|
|
||||||
// screen record automatically stops after 3 minutes
|
// screen record automatically stops after 3 minutes
|
||||||
// we need to block on a loop and split it into multiple files
|
// we need to block on a loop and split it into multiple files
|
||||||
GlobalScope.launch(Dispatchers.IO) {
|
GlobalScope.launch(Dispatchers.IO) {
|
||||||
|
|
@ -131,10 +135,16 @@ internal interface LargeTestBase : KoinComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
fun stopScreenRecord(keepRecordingScreen: AtomicBoolean) {
|
fun stopRecordingTest(
|
||||||
|
keepRecordingScreen: AtomicBoolean,
|
||||||
|
testName: String,
|
||||||
|
) {
|
||||||
keepRecordingScreen.set(false)
|
keepRecordingScreen.set(false)
|
||||||
|
|
||||||
runCommand("pkill -2 screenrecord")
|
runCommand("pkill -2 screenrecord")
|
||||||
|
|
||||||
|
// write logcat to file
|
||||||
|
val fileName = testResultFilename(testName)
|
||||||
|
runCommand("logcat -d -f $testVideoPath/$fileName.log")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun uninstallPackages(packages: Collection<PackageInfo>) {
|
fun uninstallPackages(packages: Collection<PackageInfo>) {
|
||||||
|
|
|
||||||
|
|
@ -38,13 +38,13 @@ internal abstract class SeedvaultLargeTest :
|
||||||
resetApplicationState()
|
resetApplicationState()
|
||||||
clearTestBackups()
|
clearTestBackups()
|
||||||
|
|
||||||
startScreenRecord(keepRecordingScreen, name.methodName)
|
startRecordingTest(keepRecordingScreen, name.methodName)
|
||||||
restoreBaselineBackup()
|
restoreBaselineBackup()
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
open fun tearDown() {
|
open fun tearDown() {
|
||||||
stopScreenRecord(keepRecordingScreen)
|
stopRecordingTest(keepRecordingScreen, name.methodName)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue