Skip to content

Commit

Permalink
feat(ios): use shared artifacts for multiple simulators (#840)
Browse files Browse the repository at this point in the history
  • Loading branch information
Malinskiy authored Nov 14, 2023
1 parent 47d866c commit 8feb03d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 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 @@ -58,6 +58,7 @@ class NmTestParser(
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,10 +43,10 @@ class RemoteFileManager(private val device: AppleDevice) {

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

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

/**
* Omitting xcresult extension results in a symlink
Expand All @@ -61,6 +64,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 8feb03d

Please sign in to comment.