Skip to content

Commit 6f16835

Browse files
committed
Fix flakes in FIRCrashlyticsReportTests.m
1 parent 17fdac8 commit 6f16835

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

Crashlytics/Crashlytics/Models/FIRCLSInternalReport.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// experiment
1717

1818
#import "Crashlytics/Crashlytics/Models/FIRCLSInternalReport.h"
19+
#import "Crashlytics/Crashlytics/Private/FIRCLSInternalReport_Private.h"
1920

2021
#import "Crashlytics/Crashlytics/Helpers/FIRCLSFile.h"
2122
#import "Crashlytics/Crashlytics/Helpers/FIRCLSLogger.h"
@@ -53,6 +54,8 @@ @interface FIRCLSInternalReport () {
5354

5455
@implementation FIRCLSInternalReport
5556

57+
@synthesize operationQueue = _operationQueue;
58+
5659
+ (instancetype)reportWithPath:(NSString *)path {
5760
return [[self alloc] initWithPath:path];
5861
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2025 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#import "Crashlytics/Crashlytics/Models/FIRCLSInternalReport.h"
16+
17+
NS_ASSUME_NONNULL_BEGIN
18+
19+
@interface FIRCLSInternalReport ()
20+
21+
@property(nonatomic, readonly) NSOperationQueue *operationQueue;
22+
23+
@end
24+
25+
NS_ASSUME_NONNULL_END

Crashlytics/UnitTests/FIRCrashlyticsReportTests.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#import "Crashlytics/Crashlytics/Components/FIRCLSGlobals.h"
2020
#import "Crashlytics/Crashlytics/Helpers/FIRCLSFile.h"
2121
#import "Crashlytics/Crashlytics/Models/FIRCLSInternalReport.h"
22+
#import "Crashlytics/Crashlytics/Private/FIRCLSInternalReport_Private.h"
2223
#import "Crashlytics/Crashlytics/Private/FIRCrashlyticsReport_Private.h"
2324
#import "Crashlytics/Crashlytics/Public/FirebaseCrashlytics/FIRCrashlyticsReport.h"
2425

@@ -244,6 +245,7 @@ - (void)testCustomKeysLimits {
244245
NSString *key = [NSString stringWithFormat:@"key_%i", i];
245246
[report setCustomValue:@"hello" forKey:key];
246247
}
248+
[report.internalReport.operationQueue waitUntilAllOperationsAreFinished];
247249

248250
NSArray *entriesI = FIRCLSFileReadSections(
249251
[[report.internalReport pathForContentFile:FIRCLSReportUserIncrementalKVFile]
@@ -265,6 +267,7 @@ - (void)testLogsNoExisting {
265267

266268
[report log:@"Normal log without formatting"];
267269
[report logWithFormat:@"%@, %@", @"First", @"Second"];
270+
[report.internalReport.operationQueue waitUntilAllOperationsAreFinished];
268271

269272
NSArray *entries = FIRCLSFileReadSections(
270273
[[report.internalReport pathForContentFile:FIRCLSReportLogAFile] fileSystemRepresentation],
@@ -283,6 +286,7 @@ - (void)testLogsWithExisting {
283286

284287
[report log:@"Normal log without formatting"];
285288
[report logWithFormat:@"%@, %@", @"First", @"Second"];
289+
[report.internalReport.operationQueue waitUntilAllOperationsAreFinished];
286290

287291
NSArray *entries = FIRCLSFileReadSections(
288292
[[report.internalReport pathForContentFile:FIRCLSReportLogAFile] fileSystemRepresentation],
@@ -302,6 +306,7 @@ - (void)testLogLimits {
302306
for (int i = 0; i < 2000; i++) {
303307
[report log:@"0123456789"];
304308
}
309+
[report.internalReport.operationQueue waitUntilAllOperationsAreFinished];
305310

306311
unsigned long long sizeA = [[[NSFileManager defaultManager]
307312
attributesOfItemAtPath:[report.internalReport pathForContentFile:FIRCLSReportLogAFile]

0 commit comments

Comments
 (0)