Skip to content

Commit 7244f30

Browse files
authored
don't fail for skipped tests (#62)
this CL changes the default behavior for the ci-action to not fail for skipped tests. I've also updated default locale to en_US to match androidx ifnra. Test: TestRunnerTest
1 parent 71fd27c commit 7244f30

File tree

6 files changed

+66
-5
lines changed

6 files changed

+66
-5
lines changed

AndroidXCI/cli/src/main/kotlin/dev/androidx/ci/cli/Main.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ private class Cli : CliktCommand() {
263263
AndroidDevice(
264264
orientation = "portrait",
265265
androidModelId = model.id,
266-
locale = "en",
266+
locale = "en_US",
267267
androidVersionId = spec.sdk
268268
)
269269
}

AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/testRunner/FirebaseTestLabController.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ internal class FirebaseTestLabController(
6363
?: error("Cannot find supported version for $defaultModel in test device catalog: $catalog")
6464
listOf(
6565
AndroidDevice(
66-
locale = "en",
66+
locale = "en_US",
6767
androidModelId = defaultModel.id,
6868
androidVersionId = defaultModelVersion.toString(),
6969
orientation = "portrait"

AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/testRunner/StatusReporter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ internal class StatusReporter(
5151
suspend fun reportEnd(testResult: TestResult) {
5252
val newState = when {
5353
testResult is TestResult.IncompleteRun -> CommitInfo.State.ERROR
54-
testResult.allTestsPassed -> CommitInfo.State.SUCCESS
55-
else -> CommitInfo.State.FAILURE
54+
testResult.hasFailedTest -> CommitInfo.State.FAILURE
55+
else -> CommitInfo.State.SUCCESS
5656
}
5757
updateState(state = newState)
5858
}

AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/testRunner/vo/TestResult.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package dev.androidx.ci.testRunner.vo
1919
import com.squareup.moshi.Moshi
2020
import com.squareup.moshi.adapters.PolymorphicJsonAdapterFactory
2121
import dev.androidx.ci.generated.ftl.TestMatrix
22+
import dev.androidx.ci.generated.ftl.TestMatrix.OutcomeSummary.FAILURE
2223
import dev.androidx.ci.generated.ftl.TestMatrix.OutcomeSummary.SUCCESS
2324
import dev.zacsweers.moshix.reflect.MetadataKotlinJsonAdapterFactory
2425

@@ -27,6 +28,8 @@ sealed class TestResult(
2728
) {
2829
abstract val allTestsPassed: Boolean
2930

31+
abstract val hasFailedTest: Boolean
32+
3033
abstract val failureLog: String
3134

3235
data class CompleteRun(
@@ -37,6 +40,11 @@ sealed class TestResult(
3740
it.outcomeSummary != SUCCESS
3841
}
3942
}
43+
override val hasFailedTest: Boolean by lazy {
44+
matrices.any {
45+
it.outcomeSummary == FAILURE
46+
}
47+
}
4048
override val failureLog: String
4149
get() = buildString {
4250
val failed = matrices.filter {
@@ -54,6 +62,8 @@ sealed class TestResult(
5462
) : TestResult(Type.INCOMPLETE_RUN) {
5563
override val allTestsPassed: Boolean
5664
get() = false
65+
override val hasFailedTest: Boolean
66+
get() = true
5767
override val failureLog: String
5868
get() = buildString {
5969
appendLine("FTL failed with an exception:")

AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/testRunner/StateReporterTest.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ internal class StateReporterTest {
8787
projectId = "myProject",
8888
requestId = "requestId",
8989
testMatrix = matrix
90-
)
90+
).let {
91+
it.copy(
92+
outcomeSummary = TestMatrix.OutcomeSummary.FAILURE
93+
)
94+
}
9195
reporter.reportEnd(
9296
TestResult.CompleteRun(matrices = listOf(failedTestMatrix))
9397
)

AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/testRunner/TestRunnerTest.kt

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import com.google.common.truth.Truth.assertThat
2020
import dev.androidx.ci.fake.FakeBackend
2121
import dev.androidx.ci.generated.ftl.TestMatrix
2222
import dev.androidx.ci.generated.ftl.TestMatrix.OutcomeSummary.FAILURE
23+
import dev.androidx.ci.generated.ftl.TestMatrix.OutcomeSummary.SKIPPED
2324
import dev.androidx.ci.generated.ftl.TestMatrix.OutcomeSummary.SUCCESS
2425
import dev.androidx.ci.github.dto.ArtifactsResponse
2526
import dev.androidx.ci.github.dto.CommitInfo
@@ -200,6 +201,52 @@ internal class TestRunnerTest(
200201
assertOutputFolderContents(result)
201202
}
202203

204+
@Test
205+
fun skippedTest() = testScope.runTest {
206+
val artifact1 = fakeBackend.createArchive(
207+
testPairs = listOf(
208+
FakeBackend.TestPair(
209+
testFilePrefix = "bio",
210+
testApk = "biometric-integration-tests-testapp_testapp-debug-androidTest.apk",
211+
appApk = "biometric-integration-tests-testapp_testapp-debug.apk",
212+
)
213+
),
214+
contentNames = listOf(
215+
"biometric-integration-tests-testapp_testapp-debug-androidTest.apk",
216+
"biometric-integration-tests-testapp_testapp-debug.apk",
217+
"biometric-integration-tests-testapp_testapp-release.apk"
218+
)
219+
)
220+
createRuns(
221+
listOf(
222+
artifact1
223+
)
224+
)
225+
val runTests = async {
226+
testRunner.runTests()
227+
}
228+
runCurrent()
229+
assertThat(runTests.isActive).isTrue()
230+
val testMatrices = fakeBackend.fakeFirebaseTestLabApi.getTestMatrices()
231+
assertThat(testMatrices).hasSize(1)
232+
fakeBackend.finishAllTests(SKIPPED)
233+
advanceUntilIdle()
234+
val result = runTests.await()
235+
assertThat(result.allTestsPassed).isFalse()
236+
assertThat(result.hasFailedTest).isFalse()
237+
check(result is TestResult.CompleteRun)
238+
assertThat(result.matrices).hasSize(1)
239+
result.matrices.first().let {
240+
// make sure it returns updated test matrices
241+
assertThat(it.state).isEqualTo(TestMatrix.State.FINISHED)
242+
assertThat(it.outcomeSummary).isEqualTo(TestMatrix.OutcomeSummary.SKIPPED)
243+
}
244+
assertThat(getRunState(TARGET_RUN_ID)).isEqualTo(
245+
CommitInfo.State.SUCCESS
246+
)
247+
assertOutputFolderContents(result)
248+
}
249+
203250
@Test
204251
fun multipleTestsOnMultipleArtifacts_oneFailure() = testScope.runTest {
205252
val artifact1 = fakeBackend.createArchive(

0 commit comments

Comments
 (0)