Skip to content

Commit 37affc1

Browse files
authored
Have Firestore integration tests run all tests (#3342)
* Rename FIRQueryTests to FIRQueryUnitTests * Make IntegrationTests targets run everything The incremental cost of running all tests is an extra two seconds of run time, but not starting the simulator three times during a build cuts build times by ~25%. * sync_project.rb generated changes * sync_project.rb generated changes * Remove AllTests_iOS aggregate target * Add unit test deps to Firestore_IntegrationTests_* * Fix BasicCompileTests on macOS and tvOS * Run Firestore IntegrationTests only on Travis This cuts build time for the job by about 25%, primarily due to not having to start/deploy to the simulator repeatedly.
1 parent 589c53d commit 37affc1

File tree

7 files changed

+1098
-251
lines changed

7 files changed

+1098
-251
lines changed

Firestore/Example/Firestore.xcodeproj/project.pbxproj

Lines changed: 1059 additions & 91 deletions
Large diffs are not rendered by default.

Firestore/Example/Firestore.xcodeproj/xcshareddata/xcschemes/AllTests_iOS.xcscheme

Lines changed: 0 additions & 133 deletions
This file was deleted.

Firestore/Example/Podfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ target 'Firestore_Example_iOS' do
5151
inherit! :search_paths
5252

5353
pod 'FirebaseFirestoreSwift', :path => '../../'
54+
pod 'GoogleBenchmark', :podspec => 'GoogleBenchmark.podspec'
5455
pod 'GoogleTest', :podspec => 'GoogleTest.podspec'
56+
pod 'ProtobufCpp', :podspec => 'ProtobufCpp.podspec'
5557

5658
pod 'OCMock'
5759
pod 'leveldb-library'
@@ -94,7 +96,9 @@ target 'Firestore_Example_macOS' do
9496
inherit! :search_paths
9597

9698
pod 'FirebaseFirestoreSwift', :path => '../../'
99+
pod 'GoogleBenchmark', :podspec => 'GoogleBenchmark.podspec'
97100
pod 'GoogleTest', :podspec => 'GoogleTest.podspec'
101+
pod 'ProtobufCpp', :podspec => 'ProtobufCpp.podspec'
98102

99103
pod 'OCMock'
100104
pod 'leveldb-library'
@@ -125,7 +129,9 @@ target 'Firestore_Example_tvOS' do
125129
inherit! :search_paths
126130

127131
pod 'FirebaseFirestoreSwift', :path => '../../'
132+
pod 'GoogleBenchmark', :podspec => 'GoogleBenchmark.podspec'
128133
pod 'GoogleTest', :podspec => 'GoogleTest.podspec'
134+
pod 'ProtobufCpp', :podspec => 'ProtobufCpp.podspec'
129135

130136
pod 'OCMock'
131137
pod 'leveldb-library'

Firestore/Example/Tests/API/FIRQueryTests.mm renamed to Firestore/Example/Tests/API/FIRQueryUnitTests.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929

3030
NS_ASSUME_NONNULL_BEGIN
3131

32-
@interface FIRQueryTests : XCTestCase
32+
@interface FIRQueryUnitTests : XCTestCase
3333
@end
3434

35-
@implementation FIRQueryTests
35+
@implementation FIRQueryUnitTests
3636

3737
- (void)testEquals {
3838
std::shared_ptr<api::Firestore> firestore = FSTTestFirestore().wrapped;

Firestore/Swift/Tests/API/BasicCompileTests.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@
1919

2020
import Foundation
2121
import XCTest
22-
import Firebase
22+
23+
// The Firebase pod is only available on iOS. On other platforms, import
24+
// Firestore directly and disable any tests that inspect types at the Firebase
25+
// level.
26+
#if os(iOS)
27+
import Firebase
28+
#else
29+
import FirebaseFirestore
30+
#endif
2331

2432
class BasicCompileTests: XCTestCase {
2533
func testCompiled() {
@@ -423,10 +431,14 @@ func types() {
423431
let _: Firestore
424432
let _: FirestoreSettings
425433
let _: GeoPoint
426-
let _: Firebase.GeoPoint
434+
#if os(iOS)
435+
let _: Firebase.GeoPoint
436+
#endif
427437
let _: FirebaseFirestore.GeoPoint
428438
let _: Timestamp
429-
let _: Firebase.Timestamp
439+
#if os(iOS)
440+
let _: Firebase.Timestamp
441+
#endif
430442
let _: FirebaseFirestore.Timestamp
431443
let _: ListenerRegistration
432444
let _: Query

scripts/build.sh

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -308,26 +308,18 @@ case "$product-$method-$platform" in
308308
"${firestore_emulator}" start
309309
trap '"${firestore_emulator}" stop' ERR EXIT
310310

311-
RunXcodebuild \
312-
-workspace 'Firestore/Example/Firestore.xcworkspace' \
313-
-scheme "Firestore_Tests_$platform" \
314-
"${xcb_flags[@]}" \
315-
build \
316-
test
317-
318-
# Firestore_SwiftTests_iOS require Swift 4, which needs Xcode 9
319-
if [[ "$platform" == 'iOS' && "$xcode_major" -ge 9 ]]; then
311+
if [[ "$xcode_major" -lt 9 ]]; then
312+
# When building and testing for Xcode 8, only test unit tests.
320313
RunXcodebuild \
321314
-workspace 'Firestore/Example/Firestore.xcworkspace' \
322-
-scheme "Firestore_SwiftTests_iOS" \
315+
-scheme "Firestore_Tests_$platform" \
323316
"${xcb_flags[@]}" \
324317
build \
325318
test
326-
fi
327319

328-
# Firestore_IntegrationTests_iOS require Swift 4, which needs Xcode 9
329-
# Other non-iOS platforms don't have swift integration tests yet.
330-
if [[ "$platform" != 'iOS' || "$xcode_major" -ge 9 ]]; then
320+
else
321+
# IntegrationTests run all the tests, including Swift tests, which
322+
# require Swift 4.0 and Xcode 9+.
331323
RunXcodebuild \
332324
-workspace 'Firestore/Example/Firestore.xcworkspace' \
333325
-scheme "Firestore_IntegrationTests_$platform" \

scripts/sync_project.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def sync_firestore(test_only)
118118

119119
# Other dependencies that assume #includes are relative to their roots.
120120
'"${PODS_ROOT}/../../../Firestore/third_party/abseil-cpp"',
121+
'"${PODS_ROOT}/GoogleBenchmark/include"',
121122
'"${PODS_ROOT}/GoogleTest/googlemock/include"',
122123
'"${PODS_ROOT}/GoogleTest/googletest/include"',
123124
'"${PODS_ROOT}/leveldb-library/include"',
@@ -178,14 +179,15 @@ def sync_firestore(test_only)
178179
['iOS', 'macOS', 'tvOS'].each do |platform|
179180
s.target "Firestore_IntegrationTests_#{platform}" do |t|
180181
t.source_files = [
181-
'Firestore/Example/Tests/Integration/**',
182-
'Firestore/Example/Tests/Util/FSTEventAccumulator.mm',
183-
'Firestore/Example/Tests/Util/FSTHelpers.mm',
184-
'Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm',
185-
'Firestore/Example/Tests/Util/XCTestCase+Await.mm',
186-
'Firestore/Example/Tests/en.lproj/InfoPlist.strings',
187-
'Firestore/Swift/Tests/Integration/**',
188-
'Firestore/core/test/firebase/firestore/testutil/**',
182+
'Firestore/Example/Tests/**',
183+
'Firestore/Protos/cpp/**',
184+
'Firestore/Swift/Tests/**',
185+
'Firestore/core/test/**',
186+
'Firestore/third_party/Immutable/Tests/**',
187+
]
188+
t.exclude_files = [
189+
# needs to be in project but not in target
190+
'Firestore/Example/Tests/Tests-Info.plist',
189191
]
190192
t.xcconfig = xcconfig_objc + xcconfig_swift
191193
end

0 commit comments

Comments
 (0)