From 54352d14996947ccc6a6f1122acfc11dc0db06f2 Mon Sep 17 00:00:00 2001 From: Neal Lester Date: Thu, 13 Dec 2018 12:06:57 -0800 Subject: [PATCH 1/2] Fixed bug where pendingPromiseDeallocated event was incorrectly reported as a waitOnMainThread event. Added test which should have caught this bug in the first place. --- Sources/Resolver.swift | 2 +- Tests/CorePromise/LoggingTests.swift | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Sources/Resolver.swift b/Sources/Resolver.swift index 953ece2eb..297de0325 100644 --- a/Sources/Resolver.swift +++ b/Sources/Resolver.swift @@ -8,7 +8,7 @@ public final class Resolver { deinit { if case .pending = box.inspect() { - conf.logHandler(.waitOnMainThread) + conf.logHandler(.pendingPromiseDeallocated) } } } diff --git a/Tests/CorePromise/LoggingTests.swift b/Tests/CorePromise/LoggingTests.swift index 742e4a75c..e0b3b06a3 100644 --- a/Tests/CorePromise/LoggingTests.swift +++ b/Tests/CorePromise/LoggingTests.swift @@ -153,5 +153,27 @@ class LoggingTests: XCTestCase { XCTAssertEqual(logOutput!, "waitOnMainThread") } + // Verify pendingPromiseDeallocated is logged + func testPendingPromiseDeallocatedIsLogged() { + + var logOutput: String? = nil + conf.logHandler = { event in + switch event { + case .waitOnMainThread: + logOutput = "\(event)" + case .pendingPromiseDeallocated: + logOutput = "\(event)" + case .cauterized: + // Using an enum with associated value does not convert to a string properly in + // earlier versions of swift + logOutput = "cauterized" + } + } + do { + let _ = Promise.pending() + } + XCTAssertEqual ("pendingPromiseDeallocated", logOutput!) + } + //TODO Verify pending promise deallocation is logged } From b60c53e00c70f0b6dc10c0ccc53a77bad3ef5940 Mon Sep 17 00:00:00 2001 From: Neal Lester Date: Thu, 13 Dec 2018 13:19:20 -0800 Subject: [PATCH 2/2] Kick Travis CI