Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ios): use shared artifacts for multiple simulators #840

Merged
merged 3 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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