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: Windows Updates For Integration Tests #1717

Merged
merged 11 commits into from
Mar 24, 2021
4 changes: 3 additions & 1 deletion common/src/main/kotlin/flank/common/Files.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import java.io.IOException
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.StandardCopyOption

val defaultCredentialPath: Path by lazy {
Paths.get(userHome, ".config/gcloud/application_default_credentials.json")
Expand Down Expand Up @@ -36,7 +37,8 @@ fun createCopy(sourceDirectoryLocation: String, destinationDirectoryLocation: St
copyDirectory(sourceDirectoryLocation, destinationDirectoryLocation)
}

fun createFileCopy(source: String, destination: String): Path = Files.copy(Paths.get(source), Paths.get(destination))
fun createFileCopy(source: String, destination: String): Path =
Files.copy(Paths.get(source), Paths.get(destination), StandardCopyOption.REPLACE_EXISTING)

fun copyDirectory(sourceDirectoryLocation: String, destinationDirectoryLocation: String) {
Files.walk(Paths.get(sourceDirectoryLocation))
Expand Down
2 changes: 1 addition & 1 deletion flank-scripts/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ shadowJar.apply {
}
}
// <breaking change>.<feature added>.<fix/minor change>
version = "1.9.3"
version = "1.9.5"
group = "com.github.flank"

application {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package flank.scripts.ops.updatebinaries

import flank.common.downloadFile
import flank.common.extract
import flank.common.isWindows
import java.nio.file.Files
import java.nio.file.Paths
import java.util.stream.Collectors
Expand All @@ -10,6 +11,8 @@ private val currentPath = Paths.get("")
private val atomicPath = Paths.get(currentPath.toString(), "libatomic")

fun updateAtomic() {
if (isWindows) return

val atomicDeb = Paths.get(atomicPath.toString(), "libatomic.deb").toFile()
val atomicDataTarXz = Paths.get(atomicPath.toString(), "data.tar.xz").toFile()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,14 @@ package flank.scripts.ops.updatebinaries

import flank.common.downloadFile
import flank.common.extract
import flank.scripts.utils.isWindows
import flank.common.isWindows
import java.nio.file.Files
import java.nio.file.Paths

private val currentPath = Paths.get("")
private val llvmPath = Paths.get(currentPath.toString(), "llvm")

fun updateLlvm() = if (isWindows) updateLlvmWindows() else updateLlvmNonWindows()

private fun updateLlvmWindows() {
println(" Will be available after #1134")
/*
TODO finish this in #1134
val llvmExe = Paths.get(llvmPath.toString(), "LLVM-win64.exe")
if (llvmExe.toFile().exists()) {
println("LLVM exists")
} else {
println("Downloading Windows LLVM...")
llvmPath.toFile().mkdirs()
downloadFile(
srcUrl = "https://releases.llvm.org/8.0.0/LLVM-8.0.0-win64.exe",
destinationPath = llvmExe.toString()
)
}

llvmExe.toFile().extract(llvmPath.toFile(), "zip", "xz")
findAndCopyLlvmLicense()
findAndCopyLlvmNmFile()
llvmPath.toFile().deleteRecursively()*/
}
fun updateLlvm() = if (isWindows) Unit else updateLlvmNonWindows()

private fun updateLlvmNonWindows() {
val llvmTarXz = Paths.get(llvmPath.toString(), "llvm.tar.xz")
Expand Down Expand Up @@ -67,6 +45,7 @@ private fun findAndCopyLlvmLicense() {

private fun findAndCopyLlvmNmFile() {
val llvmNmSuffix = Paths.get("bin", "llvm-nm").toString()

val llvmNmOutputFile = Paths.get(currentPath.toString(), "nm").toFile()

println("Copying llvm nm ...")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,14 @@ package flank.scripts.ops.updatebinaries

import flank.common.downloadFile
import flank.common.extract
import flank.scripts.utils.isWindows
import flank.common.isWindows
import java.nio.file.Files
import java.nio.file.Paths

private val currentPath = Paths.get("")
private val swiftPath = Paths.get(currentPath.toString(), "swift")

fun updateSwift() = if (isWindows) updateSwiftWindows() else updateSwiftOther()

private fun updateSwiftWindows() {
println(" Will be available after #1134")
/*
TODO finish this in #1134
val swiftExe = Paths.get(swiftPath.toString(), "swift.exe")

if (swiftExe.toFile().exists()) {
println("Swift exists")
} else {
println("Downloading swift for Windows")
swiftPath.toFile().mkdirs()
downloadFile(
srcUrl = "https://swift.org/builds/swift-5.3-release/windows10/swift-5.3-RELEASE/swift-5.3-RELEASE-windows10.exe",
destinationPath = swiftExe.toString()
)
}

swiftExe.toFile().extract(swiftPath.toFile(), "zip", "gz")
findAndCopySwiftLicense()
findAndCopySwiftDemangleFile()
swiftPath.toFile().deleteRecursively()*/
}
fun updateSwift() = if (isWindows) Unit else updateSwiftOther()

private fun updateSwiftOther() {
val swiftTarGz = Paths.get(swiftPath.toString(), "swift.tar.gz")
Expand Down Expand Up @@ -68,6 +45,7 @@ private fun findAndCopySwiftLicense() {

private fun findAndCopySwiftDemangleFile() {
val switftDemangleFileSuffix = Paths.get("usr", "bin", "swift-demangle").toString()

val switftDemangleOutputFile = Paths.get(currentPath.toString(), "swift-demangle").toFile()

println("Copying swift-demangle ...")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package integration

import FlankCommand
import com.google.common.truth.Truth.assertThat
import flank.common.isWindows
import org.junit.Assume.assumeFalse
import org.junit.Test
import run
import utils.CONFIGS_PATH
Expand Down Expand Up @@ -49,7 +47,6 @@ class AllTestFilteredIT {

@Test
fun `filter all tests - ios`() {
assumeFalse(isWindows)
val name = "$name-ios"
val result = FlankCommand(
flankPath = FLANK_JAR_PATH,
Expand Down
3 changes: 0 additions & 3 deletions integration_tests/src/test/kotlin/integration/DumpShardsIT.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package integration

import FlankCommand
import com.google.common.truth.Truth.assertThat
import flank.common.isWindows
import org.junit.Assume
import org.junit.Test
import run
import utils.CONFIGS_PATH
Expand Down Expand Up @@ -65,7 +63,6 @@ class DumpShardsIT {

@Test
fun `dump shards - ios`() {
Assume.assumeFalse(isWindows)
val name = "$name-ios"
val result = FlankCommand(
flankPath = FLANK_JAR_PATH,
Expand Down
1 change: 1 addition & 0 deletions test_runner/bash/flank.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -jar "flank.jar"
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private fun shouldDownloadBinaries(): Boolean {
}

private fun neededFilesListByOs(): List<String> = if (isWindows) {
listOf("libatomic.so.1", "libatomic.so.1.2.0") // more files should be added after #1134"
listOf("libatomic.so.1", "libatomic.so.1.2.0", "nm.exe", "swift-demangle.exe", "swiftDemangle.dll")
} else {
listOf("nm", "swift-demangle", "libatomic.so.1", "libatomic.so.1.2.0")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ftl.ios.xctest.common

import flank.common.appDataDirectory
import flank.common.isMacOS
import flank.common.isWindows
import ftl.util.Bash

internal fun parseObjcTests(binary: String): List<String> {
Expand All @@ -10,8 +12,8 @@ internal fun parseObjcTests(binary: String): List<String> {
val results = mutableListOf<String>()
// https://github.com/linkedin/bluepill/blob/37e7efa42472222b81adaa0e88f2bd82aa289b44/Source/Shared/BPXCTestFile.m#L18
// must quote binary path in case there are spaces
var cmd = "nm -U ${binary.quote()}"
if (!isMacOS) cmd = "PATH=~/.flank $cmd"
var cmd = if (!isWindows) "nm -U ${binary.quote()}" else "nm.exe -U ${binary.quote()}"
if (!isMacOS) cmd = if (isWindows) "PATH=$appDataDirectory\\.flank $cmd" else "PATH=~/.flank $cmd"
val output = Bash.execute(cmd)

output.lines().forEach { line ->
Expand Down
71 changes: 35 additions & 36 deletions test_runner/src/main/kotlin/ftl/run/platform/RunIosTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,47 +33,46 @@ import kotlinx.coroutines.flow.toList
// https://github.com/bootstraponline/gcloud_cli/blob/5bcba57e825fc98e690281cf69484b7ba4eb668a/google-cloud-sdk/lib/googlecloudsdk/api_lib/firebase/test/ios/matrix_creator.py#L109
// https://cloud.google.com/sdk/gcloud/reference/alpha/firebase/test/ios/run
// https://cloud.google.com/sdk/gcloud/reference/alpha/firebase/test/ios/
internal suspend fun IosArgs.runIosTests(): TestResult =
coroutineScope {
val args = this@runIosTests
val stopwatch = beforeRunTests()
internal suspend fun IosArgs.runIosTests(): TestResult = coroutineScope {
val args = this@runIosTests
val stopwatch = beforeRunTests()

val iosDeviceList = GcIosMatrix.build(devices)
val iosDeviceList = GcIosMatrix.build(devices)

val history = GcToolResults.createToolResultsHistory(args)
val otherGcsFiles = uploadOtherFiles()
val additionalIpasGcsFiles = uploadAdditionalIpas()
val history = GcToolResults.createToolResultsHistory(args)
val otherGcsFiles = uploadOtherFiles()
val additionalIpasGcsFiles = uploadAdditionalIpas()

dumpShardsIfXcTest()
saveToFlankLinks(
shardsFilePath,
FtlConstants.GCS_STORAGE_LINK + join(resultsBucket, resultsDir)
)
val testShardChunks = xcTestRunData.flattenShardChunks()
logLn(beforeRunMessage(testShardChunks))

val result = createIosTestContexts().map { context ->
GcIosTestMatrix.build(
iosDeviceList = iosDeviceList,
args = args,
iosTestContext = context,
toolResultsHistory = history,
otherFiles = otherGcsFiles,
additionalIpasGcsPaths = additionalIpasGcsFiles
)
}.repeat(repeatTests)
.map { async(Dispatchers.IO) { it.executeWithRetry() } }
.toList()
.awaitAll()
dumpShardsIfXcTest()
saveToFlankLinks(
shardsFilePath,
FtlConstants.GCS_STORAGE_LINK + join(resultsBucket, resultsDir)
)
val testShardChunks = xcTestRunData.flattenShardChunks()
logLn(beforeRunMessage(testShardChunks))

TestResult(
matrixMap = afterRunTests(
testMatrices = result,
stopwatch = stopwatch
),
shardChunks = testShardChunks.testCases
val result = createIosTestContexts().map { context ->
GcIosTestMatrix.build(
iosDeviceList = iosDeviceList,
args = args,
iosTestContext = context,
toolResultsHistory = history,
otherFiles = otherGcsFiles,
additionalIpasGcsPaths = additionalIpasGcsFiles
)
}
}.repeat(repeatTests)
.map { async(Dispatchers.IO) { it.executeWithRetry() } }
.toList()
.awaitAll()

TestResult(
matrixMap = afterRunTests(
testMatrices = result,
stopwatch = stopwatch
),
shardChunks = testShardChunks.testCases
)
}

private fun IosArgs.dumpShardsIfXcTest() = takeIf { isXcTest }?.let {
dumpShards(
Expand Down