[Gradle] Fix red CocoaPods tests which were hidden by an installation issue
This commit is contained in:
committed by
Space Team
parent
df3ec232b2
commit
e75fac271d
+26
-22
@@ -308,7 +308,7 @@ class CocoaPodsIT : BaseGradleIT() {
|
|||||||
@Test
|
@Test
|
||||||
fun testSyntheticProjectPodfilePostprocessing() {
|
fun testSyntheticProjectPodfilePostprocessing() {
|
||||||
project.gradleBuildScript().apply {
|
project.gradleBuildScript().apply {
|
||||||
appendToCocoapodsBlock("""pod("AWSMobileClient", version = "2.29.1")""")
|
appendToCocoapodsBlock("""pod("AWSMobileClient", version = "2.30.0")""")
|
||||||
|
|
||||||
appendText("""
|
appendText("""
|
||||||
|
|
||||||
@@ -1688,6 +1688,7 @@ class CocoaPodsIT : BaseGradleIT() {
|
|||||||
mode: ImportMode,
|
mode: ImportMode,
|
||||||
iosAppLocation: String?,
|
iosAppLocation: String?,
|
||||||
subprojectsToFrameworkNamesMap: Map<String, String?>,
|
subprojectsToFrameworkNamesMap: Map<String, String?>,
|
||||||
|
arch: String = "x86_64",
|
||||||
) {
|
) {
|
||||||
|
|
||||||
gradleProject.projectDir.resolve("gradle.properties")
|
gradleProject.projectDir.resolve("gradle.properties")
|
||||||
@@ -1729,6 +1730,7 @@ class CocoaPodsIT : BaseGradleIT() {
|
|||||||
"-configuration", "Release",
|
"-configuration", "Release",
|
||||||
"-workspace", "$name.xcworkspace",
|
"-workspace", "$name.xcworkspace",
|
||||||
"-scheme", name,
|
"-scheme", name,
|
||||||
|
"-arch", arch,
|
||||||
inheritIO = true // Xcode doesn't finish the process if the PIPE redirect is used.
|
inheritIO = true // Xcode doesn't finish the process if the PIPE redirect is used.
|
||||||
) {
|
) {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
@@ -1882,30 +1884,29 @@ class CocoaPodsIT : BaseGradleIT() {
|
|||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun installCocoaPods() {
|
fun ensureCocoapodsInstalled() {
|
||||||
if (cocoapodsInstallationRequired) {
|
if (!HostManager.hostIsMac) {
|
||||||
if (cocoapodsInstallationAllowed) {
|
return
|
||||||
println("Installing CocoaPods...")
|
}
|
||||||
gem("install", "--install-dir", cocoapodsInstallationRoot.absolutePath, "cocoapods", "-v", cocoapodsVersion)
|
|
||||||
} else {
|
if (shouldInstallLocalCocoapods) {
|
||||||
fail(
|
println("Installing CocoaPods...")
|
||||||
"""
|
gem("install", "--install-dir", cocoapodsInstallationRoot.absolutePath, "cocoapods", "-v", localCocoapodsVersion)
|
||||||
Running CocoaPods integration tests requires cocoapods to be installed.
|
} else if (!isCocoapodsInstalled()) {
|
||||||
Please install them manually:
|
fail(
|
||||||
gem install cocoapods
|
"""
|
||||||
Or re-run the tests with the 'installCocoapods=true' Gradle property.
|
Running CocoaPods integration tests requires cocoapods to be installed.
|
||||||
""".trimIndent()
|
Please install them manually:
|
||||||
)
|
gem install cocoapods
|
||||||
}
|
Or re-run the tests with the 'installCocoapods=true' Gradle property.
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private const val cocoapodsVersion = "1.11.0"
|
private const val localCocoapodsVersion = "1.11.0"
|
||||||
|
|
||||||
private val cocoapodsInstallationRequired: Boolean by lazy {
|
private val shouldInstallLocalCocoapods: Boolean = System.getProperty("installCocoapods").toBoolean()
|
||||||
!isCocoapodsInstalled()
|
|
||||||
}
|
|
||||||
private val cocoapodsInstallationAllowed: Boolean = System.getProperty("installCocoapods").toBoolean()
|
|
||||||
|
|
||||||
private val cocoapodsInstallationRoot: File by lazy { createTempDir("cocoapods") }
|
private val cocoapodsInstallationRoot: File by lazy { createTempDir("cocoapods") }
|
||||||
private val cocoapodsBinPath: File by lazy {
|
private val cocoapodsBinPath: File by lazy {
|
||||||
@@ -1913,6 +1914,10 @@ class CocoaPodsIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getEnvs(): Map<String, String> {
|
private fun getEnvs(): Map<String, String> {
|
||||||
|
if (!shouldInstallLocalCocoapods) {
|
||||||
|
return emptyMap()
|
||||||
|
}
|
||||||
|
|
||||||
val path = cocoapodsBinPath.absolutePath + File.pathSeparator + System.getenv("PATH")
|
val path = cocoapodsBinPath.absolutePath + File.pathSeparator + System.getenv("PATH")
|
||||||
val gemPath = System.getenv("GEM_PATH")?.let {
|
val gemPath = System.getenv("GEM_PATH")?.let {
|
||||||
cocoapodsInstallationRoot.absolutePath + File.pathSeparator + it
|
cocoapodsInstallationRoot.absolutePath + File.pathSeparator + it
|
||||||
@@ -1932,7 +1937,6 @@ class CocoaPodsIT : BaseGradleIT() {
|
|||||||
val result = runProcess(
|
val result = runProcess(
|
||||||
listOf("pod", "--version"),
|
listOf("pod", "--version"),
|
||||||
File("."),
|
File("."),
|
||||||
environmentVariables = getEnvs()
|
|
||||||
)
|
)
|
||||||
result.isSuccessful
|
result.isSuccessful
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
|
|||||||
Reference in New Issue
Block a user