Skip to content

Commit eb413b3

Browse files
authored
Delete unused commented asl tests (#3981)
1 parent 308e36a commit eb413b3

File tree

2 files changed

+0
-156
lines changed

2 files changed

+0
-156
lines changed

Example/Core/Tests/FIRLoggerTest.m

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -178,46 +178,6 @@ - (void)testLoggerInterface {
178178
XCTAssertNoThrow(FIRLogDebug(kFIRLoggerCore, kMessageCode, @"Configure %@.", @"blah"));
179179
}
180180

181-
// asl_set_filter does not perform as expected in unit test environment with simulator. The
182-
// following test only checks whether the logs have been sent to system with the default settings in
183-
// the unit test environment.
184-
- (void)testSystemLogWithDefaultStatus {
185-
#if !(BUG128) // Disable until https://github.com/firebase/firebase-ios-sdk/issues/128 is fixed
186-
// Test fails on device and iOS 9 simulators - b/38130372
187-
return;
188-
#else
189-
// Sets the time interval that we need to wait in order to fetch all the logs.
190-
NSTimeInterval timeInterval = 0.1f;
191-
// Generates a random string each time and check whether it has been logged.
192-
// Log messages with Notice level and below should be logged to system/device by default.
193-
self.randomLogString = [NSUUID UUID].UUIDString;
194-
FIRLogError(kFIRLoggerCore, kMessageCode, @"%@", self.randomLogString);
195-
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:timeInterval]];
196-
XCTAssertTrue([self logExists]);
197-
198-
self.randomLogString = [NSUUID UUID].UUIDString;
199-
FIRLogWarning(kFIRLoggerCore, kMessageCode, @"%@", self.randomLogString);
200-
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:timeInterval]];
201-
XCTAssertTrue([self logExists]);
202-
203-
self.randomLogString = [NSUUID UUID].UUIDString;
204-
FIRLogNotice(kFIRLoggerCore, kMessageCode, @"%@", self.randomLogString);
205-
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:timeInterval]];
206-
XCTAssertTrue([self logExists]);
207-
208-
// Log messages with Info level and above should NOT be logged to system/device by default.
209-
self.randomLogString = [NSUUID UUID].UUIDString;
210-
FIRLogInfo(kFIRLoggerCore, kMessageCode, @"%@", self.randomLogString);
211-
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:timeInterval]];
212-
XCTAssertFalse([self logExists]);
213-
214-
self.randomLogString = [NSUUID UUID].UUIDString;
215-
FIRLogDebug(kFIRLoggerCore, kMessageCode, @"%@", self.randomLogString);
216-
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:timeInterval]];
217-
XCTAssertFalse([self logExists]);
218-
#endif
219-
}
220-
221181
// The FIRLoggerLevel enum must match the ASL_LEVEL_* constants, but we manually redefine
222182
// them in FIRLoggerLevel.h since we cannot include <asl.h> (see b/34976089 for more details).
223183
// This test ensures the constants match.
@@ -229,43 +189,5 @@ - (void)testFIRLoggerLevelValues {
229189
XCTAssertEqual(FIRLoggerLevelDebug, ASL_LEVEL_DEBUG);
230190
}
231191

232-
// Helper functions.
233-
- (BOOL)logExists {
234-
[self drainFIRClientQueue];
235-
NSString *correctMsg =
236-
[NSString stringWithFormat:@"%@[%@] %@", kFIRLoggerCore, kMessageCode, self.randomLogString];
237-
return [self messageWasLogged:correctMsg];
238-
}
239-
240-
- (void)drainFIRClientQueue {
241-
dispatch_semaphore_t workerSemaphore = dispatch_semaphore_create(0);
242-
dispatch_async(getGULClientQueue(), ^{
243-
dispatch_semaphore_signal(workerSemaphore);
244-
});
245-
dispatch_semaphore_wait(workerSemaphore, DISPATCH_TIME_FOREVER);
246-
}
247-
248-
- (BOOL)messageWasLogged:(NSString *)message {
249-
#pragma clang diagnostic push
250-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
251-
aslmsg query = asl_new(ASL_TYPE_QUERY);
252-
asl_set_query(query, ASL_KEY_FACILITY, kGULLoggerASLClientFacilityName, ASL_QUERY_OP_EQUAL);
253-
aslresponse r = asl_search(getGULLoggerClient(), query);
254-
asl_free(query);
255-
aslmsg m;
256-
const char *val;
257-
NSMutableArray *allMsg = [[NSMutableArray alloc] init];
258-
while ((m = asl_next(r)) != NULL) {
259-
val = asl_get(m, ASL_KEY_MSG);
260-
if (val) {
261-
[allMsg addObject:[NSString stringWithUTF8String:val]];
262-
}
263-
}
264-
asl_free(m);
265-
asl_release(r);
266-
return [allMsg containsObject:message];
267-
#pragma clang pop
268-
}
269-
270192
@end
271193
#endif

GoogleUtilities/Example/Tests/Logger/GULLoggerTest.m

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -102,46 +102,6 @@ - (void)testLoggerInterface {
102102
XCTAssertNoThrow(GULLogDebug(@"my service", NO, kMessageCode, @"Configure %@.", @"blah"));
103103
}
104104

105-
// asl_set_filter does not perform as expected in unit test environment with simulator. The
106-
// following test only checks whether the logs have been sent to system with the default settings in
107-
// the unit test environment.
108-
- (void)testSystemLogWithDefaultStatus {
109-
#if !(BUG128) // Disable until https://github.com/firebase/firebase-ios-sdk/issues/128 is fixed
110-
// Test fails on device and iOS 9 simulators - b/38130372
111-
return;
112-
#else
113-
// Sets the time interval that we need to wait in order to fetch all the logs.
114-
NSTimeInterval timeInterval = 0.1f;
115-
// Generates a random string each time and check whether it has been logged.
116-
// Log messages with Notice level and below should be logged to system/device by default.
117-
self.randomLogString = [NSUUID UUID].UUIDString;
118-
GULLogError(@"my service", NO, kMessageCode, @"%@", self.randomLogString);
119-
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:timeInterval]];
120-
XCTAssertTrue([self logExists]);
121-
122-
self.randomLogString = [NSUUID UUID].UUIDString;
123-
GULLogWarning(@"my service", kMessageCode, @"%@", self.randomLogString);
124-
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:timeInterval]];
125-
XCTAssertTrue([self logExists]);
126-
127-
self.randomLogString = [NSUUID UUID].UUIDString;
128-
GULLogNotice(@"my service", kMessageCode, @"%@", self.randomLogString);
129-
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:timeInterval]];
130-
XCTAssertTrue([self logExists]);
131-
132-
// Log messages with Info level and above should NOT be logged to system/device by default.
133-
self.randomLogString = [NSUUID UUID].UUIDString;
134-
GULLogInfo(@"my service", kMessageCode, @"%@", self.randomLogString);
135-
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:timeInterval]];
136-
XCTAssertFalse([self logExists]);
137-
138-
self.randomLogString = [NSUUID UUID].UUIDString;
139-
GULLogDebug(@"my service", kMessageCode, @"%@", self.randomLogString);
140-
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:timeInterval]];
141-
XCTAssertFalse([self logExists]);
142-
#endif
143-
}
144-
145105
// The GULLoggerLevel enum must match the ASL_LEVEL_* constants, but we manually redefine
146106
// them in GULLoggerLevel.h since we cannot include <asl.h> (see b/34976089 for more details).
147107
// This test ensures the constants match.
@@ -153,43 +113,5 @@ - (void)testGULLoggerLevelValues {
153113
XCTAssertEqual(GULLoggerLevelDebug, ASL_LEVEL_DEBUG);
154114
}
155115

156-
// Helper functions.
157-
- (BOOL)logExists {
158-
[self drainGULClientQueue];
159-
NSString *correctMsg =
160-
[NSString stringWithFormat:@"%@[%@] %@", @"my service", kMessageCode, self.randomLogString];
161-
return [self messageWasLogged:correctMsg];
162-
}
163-
164-
- (void)drainGULClientQueue {
165-
dispatch_semaphore_t workerSemaphore = dispatch_semaphore_create(0);
166-
dispatch_async(getGULClientQueue(), ^{
167-
dispatch_semaphore_signal(workerSemaphore);
168-
});
169-
dispatch_semaphore_wait(workerSemaphore, DISPATCH_TIME_FOREVER);
170-
}
171-
172-
- (BOOL)messageWasLogged:(NSString *)message {
173-
#pragma clang diagnostic push
174-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
175-
aslmsg query = asl_new(ASL_TYPE_QUERY);
176-
asl_set_query(query, ASL_KEY_FACILITY, kGULLoggerASLClientFacilityName, ASL_QUERY_OP_EQUAL);
177-
aslresponse r = asl_search(getGULLoggerClient(), query);
178-
asl_free(query);
179-
aslmsg m;
180-
const char *val;
181-
NSMutableArray *allMsg = [[NSMutableArray alloc] init];
182-
while ((m = asl_next(r)) != NULL) {
183-
val = asl_get(m, ASL_KEY_MSG);
184-
if (val) {
185-
[allMsg addObject:[NSString stringWithUTF8String:val]];
186-
}
187-
}
188-
asl_free(m);
189-
asl_release(r);
190-
return [allMsg containsObject:message];
191-
#pragma clang pop
192-
}
193-
194116
@end
195117
#endif

0 commit comments

Comments
 (0)