Skip to content

Commit 0e1abd6

Browse files
authored
Merge pull request #198 from shepeliev/fix_ios_tests
Fix iOS tests, upgrade iOS Firebase SDK
2 parents 278221c + aa52640 commit 0e1abd6

File tree

15 files changed

+128
-18
lines changed

15 files changed

+128
-18
lines changed

.github/workflows/pull_request.yml

+16-2
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,20 @@ jobs:
3030
run: ./gradlew assemble
3131
- name: Run JS Tests
3232
run: ./gradlew cleanTest jsTest
33-
- name: Upload test artifact
33+
- name: Upload JS test artifact
3434
uses: actions/upload-artifact@v2
3535
if: failure()
3636
with:
37-
name: "JSTest Report HTML"
37+
name: "JS Test Report HTML"
3838
path: "firebase-firestore/build/reports/tests/jsTest/"
39+
- name: Run iOS Tests
40+
run: ./gradlew cleanTest iosX64Test
41+
- name: Upload iOS test artifact
42+
uses: actions/upload-artifact@v2
43+
if: failure()
44+
with:
45+
name: "iOS Test Report HTML"
46+
path: "firebase-firestore/build/reports/tests/iosTest/"
3947
- name: Run Android Instrumented Tests
4048
uses: reactivecircus/android-emulator-runner@v2
4149
with:
@@ -44,3 +52,9 @@ jobs:
4452
arch: x86_64
4553
profile: Nexus 6
4654
script: ./gradlew connectedAndroidTest
55+
- name: Upload Android test artifact
56+
uses: actions/upload-artifact@v2
57+
if: failure()
58+
with:
59+
name: "Android Test Report HTML"
60+
path: "firebase-firestore/build/reports/tests/androidTests/"
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json" == 8.1.1
1+
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json" == 8.2.0

firebase-app/src/nativeInterop/cinterop/FirebaseCore.def

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ language = Objective-C
22
package = cocoapods.FirebaseCore
33
modules = FirebaseCore
44
compilerOpts = -framework FirebaseCore
5-
linkerOpts = -framework FirebaseCore -framework FirebaseCoreDiagnostics -framework FirebaseAnalytics -framework FIRAnalyticsConnector -framework GoogleAppMeasurement -framework FirebaseInstallations -framework GoogleDataTransport -framework GoogleUtilities -framework PromisesObjC -framework nanopb -framework StoreKit -lsqlite3
5+
linkerOpts = -framework FirebaseCore -framework FirebaseCoreDiagnostics -framework FirebaseAnalytics -framework GoogleAppMeasurement -framework FirebaseInstallations -framework GoogleDataTransport -framework GoogleUtilities -framework PromisesObjC -framework nanopb -framework StoreKit -lsqlite3

firebase-auth/build.gradle.kts

+16
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,22 @@ kotlin {
7676
fun nativeTargetConfig(): KotlinNativeTarget.() -> Unit = {
7777
val nativeFrameworkPaths = listOf(
7878
rootProject.project("firebase-app").projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/iOS")
79+
).plus(
80+
listOf(
81+
"FirebaseAnalytics",
82+
"FirebaseCore",
83+
"FirebaseCoreDiagnostics",
84+
"FirebaseInstallations",
85+
"GoogleAppMeasurement",
86+
"GoogleDataTransport",
87+
"GoogleUtilities",
88+
"nanopb",
89+
"PromisesObjC"
90+
).map {
91+
val archVariant = if (konanTarget is KonanTarget.IOS_X64) "ios-arm64_i386_x86_64-simulator" else "ios-arm64_armv7"
92+
93+
rootProject.project("firebase-app").projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/$it.xcframework/$archVariant")
94+
}
7995
).plus(
8096
listOf(
8197
"FirebaseAuth",

firebase-auth/src/androidAndroidTest/kotlin/dev/gitlive/firebase/auth/auth.kt

+12-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,22 @@
55
@file:JvmName("tests")
66
package dev.gitlive.firebase.auth
77

8+
import android.util.Log
89
import androidx.test.platform.app.InstrumentationRegistry
910
import kotlinx.coroutines.runBlocking
1011

1112
actual val emulatorHost: String = "10.0.2.2"
1213

1314
actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext
1415

15-
actual fun runTest(test: suspend () -> Unit) = runBlocking { test() }
16+
actual val currentPlatform: Platform = Platform.Android
17+
18+
actual fun runTest(skip: Boolean, test: suspend () -> Unit) = runBlocking {
19+
if (skip) {
20+
Log.w("Test", "Skip the test.")
21+
return@runBlocking
22+
}
23+
24+
test()
25+
}
26+

firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt

+13-7
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ import kotlin.test.*
1010

1111
expect val emulatorHost: String
1212
expect val context: Any
13-
expect fun runTest(test: suspend () -> Unit)
13+
expect fun runTest(skip: Boolean = false, test: suspend () -> Unit)
14+
expect val currentPlatform: Platform
15+
16+
enum class Platform { Android, IOS, JS }
1417

1518
class FirebaseAuthTest {
1619

20+
// Skip the tests on iOS simulator due keychain exceptions
21+
private val skip = currentPlatform == Platform.IOS
22+
1723
@BeforeTest
1824
fun initializeFirebase() {
1925
Firebase
@@ -35,14 +41,14 @@ class FirebaseAuthTest {
3541
}
3642

3743
@Test
38-
fun testSignInWithUsernameAndPassword() = runTest {
44+
fun testSignInWithUsernameAndPassword() = runTest(skip) {
3945
val uid = getTestUid("[email protected]", "test123")
4046
val result = Firebase.auth.signInWithEmailAndPassword("[email protected]", "test123")
4147
assertEquals(uid, result.user!!.uid)
4248
}
4349

4450
@Test
45-
fun testCreateUserWithEmailAndPassword() = runTest {
51+
fun testCreateUserWithEmailAndPassword() = runTest(skip) {
4652
val email = "test+${Random.nextInt(100000)}@test.com"
4753
val createResult = Firebase.auth.createUserWithEmailAndPassword(email, "test123")
4854
assertNotEquals(null, createResult.user?.uid)
@@ -57,7 +63,7 @@ class FirebaseAuthTest {
5763
}
5864

5965
@Test
60-
fun testFetchSignInMethods() = runTest {
66+
fun testFetchSignInMethods() = runTest(skip) {
6167
val email = "test+${Random.nextInt(100000)}@test.com"
6268
var signInMethodResult = Firebase.auth.fetchSignInMethodsForEmail(email)
6369
assertEquals(emptyList(), signInMethodResult)
@@ -69,7 +75,7 @@ class FirebaseAuthTest {
6975
}
7076

7177
@Test
72-
fun testSendEmailVerification() = runTest {
78+
fun testSendEmailVerification() = runTest(skip) {
7379
val email = "test+${Random.nextInt(100000)}@test.com"
7480
val createResult = Firebase.auth.createUserWithEmailAndPassword(email, "test123")
7581
assertNotEquals(null, createResult.user?.uid)
@@ -79,7 +85,7 @@ class FirebaseAuthTest {
7985
}
8086

8187
@Test
82-
fun sendPasswordResetEmail() = runTest {
88+
fun sendPasswordResetEmail() = runTest(skip) {
8389
val email = "test+${Random.nextInt(100000)}@test.com"
8490
val createResult = Firebase.auth.createUserWithEmailAndPassword(email, "test123")
8591
assertNotEquals(null, createResult.user?.uid)
@@ -90,7 +96,7 @@ class FirebaseAuthTest {
9096
}
9197

9298
@Test
93-
fun testSignInWithCredential() = runTest {
99+
fun testSignInWithCredential() = runTest(skip) {
94100
val uid = getTestUid("[email protected]", "test123")
95101
val credential = EmailAuthProvider.credential("[email protected]", "test123")
96102
val result = Firebase.auth.signInWithCredential(credential)

firebase-auth/src/iosTest/kotlin/dev/gitlive/firebase/auth/auth.kt

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ actual val emulatorHost: String = "localhost"
1111

1212
actual val context: Any = Unit
1313

14-
actual fun runTest(test: suspend () -> Unit) = runBlocking {
14+
actual val currentPlatform: Platform = Platform.IOS
15+
16+
actual fun runTest(skip: Boolean, test: suspend () -> Unit) = runBlocking {
17+
if (skip) {
18+
NSLog("Skip the test.")
19+
return@runBlocking
20+
}
21+
1522
val testRun = MainScope().async { test() }
1623
while (testRun.isActive) {
1724
NSRunLoop.mainRunLoop.runMode(

firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,15 @@ actual val emulatorHost: String = "localhost"
1111

1212
actual val context: Any = Unit
1313

14-
actual fun runTest(test: suspend () -> Unit) = GlobalScope
14+
actual val currentPlatform: Platform = Platform.JS
15+
16+
actual fun runTest(skip: Boolean, test: suspend () -> Unit) = GlobalScope
1517
.promise {
18+
if (skip) {
19+
console.log("Skip the test.")
20+
return@promise
21+
}
22+
1623
try {
1724
test()
1825
} catch (e: dynamic) {
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAuthBinary.json" == 8.1.0
1+
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAuthBinary.json" == 8.2.0

firebase-database/build.gradle.kts

+16
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,22 @@ kotlin {
5252
fun nativeTargetConfig(): KotlinNativeTarget.() -> Unit = {
5353
val nativeFrameworkPaths = listOf(
5454
rootProject.project("firebase-app").projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/iOS")
55+
).plus(
56+
listOf(
57+
"FirebaseAnalytics",
58+
"FirebaseCore",
59+
"FirebaseCoreDiagnostics",
60+
"FirebaseInstallations",
61+
"GoogleAppMeasurement",
62+
"GoogleDataTransport",
63+
"GoogleUtilities",
64+
"nanopb",
65+
"PromisesObjC"
66+
).map {
67+
val archVariant = if (konanTarget is KonanTarget.IOS_X64) "ios-arm64_i386_x86_64-simulator" else "ios-arm64_armv7"
68+
69+
rootProject.project("firebase-app").projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/$it.xcframework/$archVariant")
70+
}
5571
).plus(
5672
listOf(
5773
"FirebaseDatabase",
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseDatabaseBinary.json" == 8.1.0
1+
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseDatabaseBinary.json" == 8.2.0

firebase-firestore/build.gradle.kts

+17
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,29 @@ kotlin {
5555
fun nativeTargetConfig(): KotlinNativeTarget.() -> Unit = {
5656
val nativeFrameworkPaths = listOf(
5757
rootProject.project("firebase-app").projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/iOS")
58+
).plus(
59+
listOf(
60+
"FirebaseAnalytics",
61+
"FirebaseCore",
62+
"FirebaseCoreDiagnostics",
63+
"FirebaseInstallations",
64+
"GoogleAppMeasurement",
65+
"GoogleDataTransport",
66+
"GoogleUtilities",
67+
"nanopb",
68+
"PromisesObjC"
69+
).map {
70+
val archVariant = if (konanTarget is KonanTarget.IOS_X64) "ios-arm64_i386_x86_64-simulator" else "ios-arm64_armv7"
71+
72+
rootProject.project("firebase-app").projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/$it.xcframework/$archVariant")
73+
}
5874
).plus(
5975
listOf(
6076
"abseil",
6177
"BoringSSL-GRPC",
6278
"FirebaseFirestore",
6379
"gRPC-Core",
80+
"gRPC-C++",
6481
"leveldb-library"
6582
).map {
6683
val archVariant = if (konanTarget is KonanTarget.IOS_X64) "ios-arm64_i386_x86_64-simulator" else "ios-arm64_armv7"
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseFirestoreBinary.json" == 8.1.0
1+
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseFirestoreBinary.json" == 8.2.0

firebase-functions/build.gradle.kts

+16
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ kotlin {
4747
fun nativeTargetConfig(): KotlinNativeTarget.() -> Unit = {
4848
val nativeFrameworkPaths = listOf(
4949
rootProject.project("firebase-app").projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/iOS")
50+
).plus(
51+
listOf(
52+
"FirebaseAnalytics",
53+
"FirebaseCore",
54+
"FirebaseCoreDiagnostics",
55+
"FirebaseInstallations",
56+
"GoogleAppMeasurement",
57+
"GoogleDataTransport",
58+
"GoogleUtilities",
59+
"nanopb",
60+
"PromisesObjC"
61+
).map {
62+
val archVariant = if (konanTarget is KonanTarget.IOS_X64) "ios-arm64_i386_x86_64-simulator" else "ios-arm64_armv7"
63+
64+
rootProject.project("firebase-app").projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/$it.xcframework/$archVariant")
65+
}
5066
).plus(
5167
listOf(
5268
"FirebaseFunctions",
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseFunctionsBinary.json" == 8.1.0
1+
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseFunctionsBinary.json" == 8.2.0

0 commit comments

Comments
 (0)