Skip to content

Commit 1d21877

Browse files
glbrnttWendellXY
authored andcommitted
Do not check source of logs in tests (grpc#1566)
Motivation: swift-log captures the 'source' of a log, which is usually the defining module. In older Swift versions this was done by parsing `#file` and was not always correct as it would just take the directory containing the file rather than the source module: we added a check after each test in gRPC to make sure the source was always "GRPC". This is no longer necessary as swift-log now does the right thing. Modifications: - Remove the check Result: Tests are slightly faster.
1 parent c8713bd commit 1d21877

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

Tests/GRPCTests/GRPCTestCase.swift

+1-12
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,10 @@ class GRPCTestCase: XCTestCase {
3636
}
3737

3838
override func tearDown() {
39-
let logs = self.capturedLogs()
40-
41-
// The default source emitted by swift-log is the directory containing the '#filePath' in which the
42-
// log was emitted. It's meant to represent the system which emitted the log, typically the
43-
// module name. In most cases it's right but in a few places, i.e. where the source lives in
44-
// child directories below 'GRPC', it isn't. We'll use this as a sanity check.
45-
//
46-
// See also: https://github.com/apple/swift-log/issues/145
47-
for log in logs {
48-
XCTAssertEqual(log.source, "GRPC", "Incorrect log source in \(log.file) on line \(log.line)")
49-
}
50-
5139
// Only print logs when there's a failure and we're *not* always logging (when we are always
5240
// logging, logs will be printed as they're caught).
5341
if !GRPCTestCase.alwaysLog, (self.testRun.map { $0.totalFailureCount > 0 } ?? false) {
42+
let logs = self.capturedLogs()
5443
self.printCapturedLogs(logs)
5544
}
5645

0 commit comments

Comments
 (0)