Repository: firebase/firebase-ios-sdk (language: cpp)

Issue:
Firestore cmake CI tests failing in GHA
It seems that a GHA infra change caused the cmake job to start failing. Perhaps related to changing the default from Xcode 12 to Xcode 13

```
/Users/runner/work/firebase-ios-sdk/firebase-ios-sdk/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm:560: error: -[FIRValidationTests testQueriesFilteredByDocumentIdMustUseStringsOrDocumentReferences] : ((FSTRemoveExceptionPrefix(exception.reason)) equal to (FSTRemoveExceptionPrefix(reason))) failed: ("Invalid query. When querying by document ID you must provide a valid string or DocumentReference, but it was of type: NSConstantIntegerNumber") is not equal to ("Invalid query. When querying by document ID you must provide a valid string or DocumentReference, but it was of type: __NSCFNumber")
Test Case '-[FIRValidationTests testQueriesFilteredByDocumentIdMustUseStringsOrDocumentReferences]' failed (0.385 seconds).
Test Case '-[FIRValidationTests testQueriesInAndArrayContainsAnyArrayRules]' started.
Test Case '-[FIRValidationTests testQueriesInAndArrayContainsAnyArrayRules]' passed (0.039 seconds).
Test Case '-[FIRValidationTests testQueriesUsingInAndDocumentIdMustHaveProperDocumentReferencesInArray]' started.
/Users/runner/work/firebase-ios-sdk/firebase-ios-sdk/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm:591: error: -[FIRValidationTests testQueriesUsingInAndDocumentIdMustHaveProperDocumentReferencesInArray] : ((FSTRemoveExceptionPrefix(exception.reason)) equal to (FSTRemoveExceptionPrefix(reason))) failed: ("Invalid query. When querying by document ID you must provide a valid string or DocumentReference, but it was of type: NSConstantArray") is not equal to ("Invalid query. When querying by document ID you must provide a valid string or DocumentReference, but it was of type: __NSArrayI")
Test Case '-[FIRValidationTests testQueriesUsingInAndDocumentIdMustHaveProperDocumentReferencesInArray]' failed (0.030 seconds).

```

https://github.com/firebase/firebase-ios-sdk/runs/3953978782?check_suite_focus=true


Discussion / hints:

Fix patch:
diff --git a/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm b/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm
index 9a35074cd4b..cb180435cc9 100644
--- a/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm
+++ b/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm
@@ -556,8 +556,9 @@ - (void)testQueriesFilteredByDocumentIdMustUseStringsOrDocumentReferences {
       [collection queryWhereFieldPath:[FIRFieldPath documentID] isEqualTo:@"foo/bar/baz"], reason);
 
   reason = @"Invalid query. When querying by document ID you must provide a valid string or "
-            "DocumentReference, but it was of type: __NSCFNumber";
-  FSTAssertThrows([collection queryWhereFieldPath:[FIRFieldPath documentID] isEqualTo:@1], reason);
+            "DocumentReference, but it was of type:";
+  FSTAssertExceptionPrefix([collection queryWhereFieldPath:[FIRFieldPath documentID] isEqualTo:@1],
+                           reason);
 
   reason = @"Invalid query. When querying a collection group by document ID, the value "
             "provided must result in a valid document path, but 'foo/bar/baz' is not because it "
@@ -586,9 +587,10 @@ - (void)testQueriesUsingInAndDocumentIdMustHaveProperDocumentReferencesInArray {
                   reason);
 
   reason = @"Invalid query. When querying by document ID you must provide a valid string or "
-            "DocumentReference, but it was of type: __NSArrayI";
+            "DocumentReference, but it was of type:";
   NSArray *value = @[ @1, @2 ];
-  FSTAssertThrows([collection queryWhereFieldPath:[FIRFieldPath documentID] in:value], reason);
+  FSTAssertExceptionPrefix([collection queryWhereFieldPath:[FIRFieldPath documentID] in:value],
+                           reason);
 
   reason = @"Invalid query. When querying a collection group by document ID, the value "
             "provided must result in a valid document path, but 'foo' is not because it "
diff --git a/Firestore/Example/Tests/Util/FSTHelpers.h b/Firestore/Example/Tests/Util/FSTHelpers.h
index e851d4f7202..6056ce75763 100644
--- a/Firestore/Example/Tests/Util/FSTHelpers.h
+++ b/Firestore/Example/Tests/Util/FSTHelpers.h
@@ -67,6 +67,10 @@ inline NSString *FSTRemoveExceptionPrefix(NSString *exception) {
   }
 }
 
+inline NSString *FSTTakeMessagePrefix(NSString *exception, NSInteger length) {
+  return [exception substringToIndex:length];
+}
+
 // Helper for validating API exceptions.
 #define FSTAssertThrows(expression, exceptionReason, ...)               \
   do {                                                                  \
@@ -81,6 +85,23 @@ inline NSString *FSTRemoveExceptionPrefix(NSString *exception) {
     XCTAssertTrue(didThrow, ##__VA_ARGS__);                             \
   } while (0)
 
+// Helper for validating API exceptions.
+#define FSTAssertExceptionPrefix(expression, prefix, ...)                   \
+  do {                                                                      \
+    BOOL didThrow = NO;                                                     \
+    @try {                                                                  \
+      (void)(expression);                                                   \
+    } @catch (NSException * exception) {                                    \
+      didThrow = YES;                                                       \
+      NSString *expectedMessage = FSTRemoveExceptionPrefix(prefix);         \
+      NSString *actualMessage = FSTRemoveExceptionPrefix(exception.reason); \
+      NSInteger length = expectedMessage.length;                            \
+      XCTAssertEqualObjects(FSTTakeMessagePrefix(actualMessage, length),    \
+                            FSTTakeMessagePrefix(expectedMessage, length)); \
+    }                                                                       \
+    XCTAssertTrue(didThrow, ##__VA_ARGS__);                                 \
+  } while (0)
+
 /** Creates a new NSDate from components. Note that year, month, and day are all one-based. */
 NSDate *FSTTestDate(int year, int month, int day, int hour, int minute, int second);
 


Test patch: