Skip to content

Commit

Permalink
Fix iOS test running when shard count is 1
Browse files Browse the repository at this point in the history
  • Loading branch information
bootstraponline committed Dec 7, 2018
1 parent d48ed79 commit 5bf70ca
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
9 changes: 8 additions & 1 deletion test_runner/src/main/kotlin/ftl/gc/GcIosTestMatrix.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.google.api.services.testing.model.TestSpecification
import com.google.api.services.testing.model.ToolResultsHistory
import ftl.args.IosArgs
import ftl.ios.Xctestrun
import ftl.ios.Xctestrun.toByteArray
import ftl.util.ShardCounter
import ftl.util.Utils.fatalError
import ftl.util.Utils.join
Expand All @@ -41,7 +42,13 @@ object GcIosTestMatrix {
val matrixGcsPath = join(gcsBucket, matrixGcsSuffix)
val methods = args.testShardChunks.elementAt(testShardsIndex)

val generatedXctestrun = Xctestrun.rewrite(xcTestParsed, methods)
// Parameterized tests on iOS don't shard correctly.
// Avoid changing Xctestrun file when test shards is 1.
val generatedXctestrun = if (args.testShards == 1) {
xcTestParsed.toByteArray()
} else {
Xctestrun.rewrite(xcTestParsed, methods)
}
val xctestrunFileGcsPath = GcStorage.uploadXCTestFile(args, gcsBucket, matrixGcsSuffix, generatedXctestrun)

val iOSXCTest = IosXcTest()
Expand Down
6 changes: 5 additions & 1 deletion test_runner/src/main/kotlin/ftl/ios/Xctestrun.kt
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,12 @@ object Xctestrun {
setOnlyTestIdentifiers(testDictionary, methods)
}

return rootClone.toByteArray()
}

fun NSDictionary.toByteArray(): ByteArray {
val out = ByteArrayOutputStream()
PropertyListParser.saveAsXML(rootClone, out)
PropertyListParser.saveAsXML(this, out)
return out.toByteArray()
}
}
4 changes: 2 additions & 2 deletions test_runner/src/main/kotlin/ftl/run/AndroidTestRunner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ object AndroidTestRunner {
val apks = resolveApks(androidArgs, runGcsPath)
val jobs = arrayListOf<Deferred<TestMatrix>>()
val runCount = androidArgs.repeatTests
val deviceCount = androidArgs.testShardChunks.size
val shardCount = androidArgs.testShardChunks.size
val shardCounter = ShardCounter()
val history = GcToolResults.createToolResultsHistory(androidArgs)

println(GenericTestRunner.beforeRunMessage(androidArgs))
repeat(runCount) {
repeat(deviceCount) { testShardsIndex ->
repeat(shardCount) { testShardsIndex ->
jobs += async {
GcAndroidTestMatrix.build(
appApkGcsPath = apks.first,
Expand Down
4 changes: 2 additions & 2 deletions test_runner/src/main/kotlin/ftl/run/IosTestRunner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ object IosTestRunner {

val jobs = arrayListOf<Deferred<TestMatrix>>()
val runCount = iosArgs.repeatTests
val deviceCount = iosArgs.testShardChunks.size
val shardCount = iosArgs.testShardChunks.size
val shardCounter = ShardCounter()
val history = GcToolResults.createToolResultsHistory(iosArgs)

println(beforeRunMessage(iosArgs))
repeat(runCount) {
repeat(deviceCount) { testShardsIndex ->
repeat(shardCount) { testShardsIndex ->
jobs += async {
GcIosTestMatrix.build(
iosDeviceList = iosDeviceList,
Expand Down

0 comments on commit 5bf70ca

Please sign in to comment.