From 85b835863fe8bbf8a2bf195543936f0c5f122cd7 Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Wed, 4 Apr 2018 19:17:02 +0100 Subject: [PATCH] Wait for test cleanup. (#280) Motivation: The current test function does not wait for the futures from close to return, and so they may in principle be leaked. This obscures errors that the test might hit with precondition failures. Modifications: Changed the defer statements to wait for the futures. Result: Fewer spurious test failures. --- Tests/NIOTests/EchoServerClientTest.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/NIOTests/EchoServerClientTest.swift b/Tests/NIOTests/EchoServerClientTest.swift index 935997866..d94a878a7 100644 --- a/Tests/NIOTests/EchoServerClientTest.swift +++ b/Tests/NIOTests/EchoServerClientTest.swift @@ -653,7 +653,7 @@ class EchoServerClientTest : XCTestCase { }.bind(host: "127.0.0.1", port: 0).wait() defer { - _ = serverChannel.close() + XCTAssertNoThrow(try serverChannel.syncCloseAcceptingAlreadyClosed()) } let clientChannel = try ClientBootstrap(group: group) @@ -666,7 +666,7 @@ class EchoServerClientTest : XCTestCase { } }.connect(to: serverChannel.localAddress!).wait() defer { - _ = clientChannel.close() + XCTAssertNoThrow(try clientChannel.syncCloseAcceptingAlreadyClosed()) } dpGroup.wait()