Skip to content

Commit

Permalink
feat(ios): use shared artifacts for multiple simulators
Browse files Browse the repository at this point in the history
  • Loading branch information
Malinskiy committed Sep 8, 2023
1 parent ca7f42a commit 4b3a25e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class AppleApplicationInstaller(
val remoteXctest = device.remoteFileManager.remoteXctestFile()
withRetry(3, 1000L) {
device.remoteFileManager.createRemoteDirectory()
val remoteDirectory = device.remoteFileManager.remoteDirectory()
if (!device.pushFolder(xctest, remoteXctest)) {
throw DeviceSetupException("Error transferring $xctest to ${device.serialNumber}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class AppleSimulatorDevice(
}
override val coroutineContext: CoroutineContext = dispatcher
override val remoteFileManager: RemoteFileManager = RemoteFileManager(this)
override val storagePath = "/tmp/marathon/$udid"
override val storagePath = "$SHARED_PATH/$udid"
private lateinit var xcodeVersion: XcodeVersion

/**
Expand Down Expand Up @@ -188,6 +188,7 @@ class AppleSimulatorDevice(
track.trackDevicePreparing(this@AppleSimulatorDevice) {
remoteFileManager.removeRemoteDirectory()
remoteFileManager.createRemoteDirectory()
remoteFileManager.createRemoteSharedDirectory()
//Clean slate for the recorder
executeWorkerCommand(listOf("pkill", "-f", "'simctl io ${udid} recordVideo'"))
mutableListOf<Deferred<Unit>>().apply {
Expand Down Expand Up @@ -750,4 +751,8 @@ class AppleSimulatorDevice(
suspend fun grant(permission: Permission, bundleId: String): Boolean {
return binaryEnvironment.xcrun.simctl.privacy.grant(udid, permission, bundleId).successful
}

companion object {
const val SHARED_PATH = "/tmp/marathon"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class AppleTestParser(
logger.debug { "Found test binary $testBinary for xctest $xctest" }

device.remoteFileManager.createRemoteDirectory()
device.remoteFileManager.createRemoteSharedDirectory()
val remoteXctest = device.remoteFileManager.remoteXctestFile()
if (!device.pushFile(xctest, remoteXctest)) {
throw TestParsingException("failed to push xctest for test parsing")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class RemoteFileManager(private val device: AppleDevice) {
private val outputDir by lazy { device.storagePath }

fun remoteDirectory(): String = outputDir
fun remoteSharedDirectory(): String = AppleSimulatorDevice.SHARED_PATH + "/shared/"

suspend fun createRemoteDirectory(remoteDir: String = remoteDirectory()) {
executeCommand(
Expand All @@ -24,6 +25,8 @@ class RemoteFileManager(private val device: AppleDevice) {
)
}

suspend fun createRemoteSharedDirectory() = createRemoteDirectory(remoteSharedDirectory())

suspend fun removeRemoteDirectory() {
executeCommand(
listOf("rm", "-rf", remoteDirectory()),
Expand All @@ -40,9 +43,9 @@ class RemoteFileManager(private val device: AppleDevice) {

fun remoteXctestrunFile(): String = remoteFile(xctestrunFileName())

fun remoteXctestFile(): String = remoteFile(xctestFileName())
fun remoteApplication(): String = remoteFile(appUnderTestFileName())
fun remoteExtraApplication(name: String) = remoteFile(name)
fun remoteXctestFile(): String = remoteSharedFile(xctestFileName())
fun remoteApplication(): String = remoteSharedFile(appUnderTestFileName())
fun remoteExtraApplication(name: String) = remoteSharedFile(name)

/**
* Omitting xcresult extension results in a symlink
Expand All @@ -58,6 +61,7 @@ class RemoteFileManager(private val device: AppleDevice) {
"${device.udid}.${batch.id}.xcresult"

private fun remoteFile(file: String): String = remoteDirectory().resolve(file)
private fun remoteSharedFile(file: String): String = remoteSharedDirectory().resolve(file)

private suspend fun safeExecuteCommand(command: List<String>) {
try {
Expand Down

0 comments on commit 4b3a25e

Please sign in to comment.