Skip to content

Commit e41fb71

Browse files
authored
mobile: Fix missing logging output in Swift integration tests (envoyproxy#36040)
In Swift, `print` goes to stdout buffering. The fix is to flush the `stdout` and `stderr` before the end of the test. See swiftlang/swift-corelibs-xctest#422 (comment) Risk Level: low (tests only) Testing: CI Docs Changes: n/a Release Notes: n/a Platform Specific Features: n/a --------- Signed-off-by: Fredy Wijaya <fredyw@google.com>
1 parent c57ddb6 commit e41fb71

18 files changed

+129
-8
lines changed

mobile/test/swift/integration/CancelGRPCStreamTest.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ final class CancelGRPCStreamTests: XCTestCase {
1111
register_test_extensions()
1212
}
1313

14+
override static func tearDown() {
15+
super.tearDown()
16+
// Flush the stdout and stderror to show the print output.
17+
fflush(stdout)
18+
fflush(stderr)
19+
}
20+
1421
func testCancelGRPCStream() {
1522
let filterName = "cancel_validation_filter"
1623

mobile/test/swift/integration/CancelStreamTest.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ final class CancelStreamTests: XCTestCase {
1111
register_test_extensions()
1212
}
1313

14+
override static func tearDown() {
15+
super.tearDown()
16+
// Flush the stdout and stderror to show the print output.
17+
fflush(stdout)
18+
fflush(stderr)
19+
}
20+
1421
func testCancelStream() {
1522
let filterName = "cancel_validation_filter"
1623

mobile/test/swift/integration/EndToEndNetworkingTest.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ final class EndToEndNetworkingTest: XCTestCase {
1010
register_test_extensions()
1111
}
1212

13+
override static func tearDown() {
14+
super.tearDown()
15+
// Flush the stdout and stderror to show the print output.
16+
fflush(stdout)
17+
fflush(stderr)
18+
}
19+
1320
func testNetworkRequestReturnsHeadersAndData() {
1421
EnvoyTestServer.startHttp1PlaintextServer()
1522
EnvoyTestServer.setHeadersAndData(

mobile/test/swift/integration/EngineApiTest.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ final class EngineApiTest: XCTestCase {
99
register_test_extensions()
1010
}
1111

12+
override static func tearDown() {
13+
super.tearDown()
14+
// Flush the stdout and stderror to show the print output.
15+
fflush(stdout)
16+
fflush(stderr)
17+
}
18+
1219
func testEngineApis() throws {
1320
let engineExpectation = self.expectation(description: "Engine Running")
1421

mobile/test/swift/integration/FilterResetIdleTest.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ final class FilterResetIdleTests: XCTestCase {
1111
register_test_extensions()
1212
}
1313

14+
override static func tearDown() {
15+
super.tearDown()
16+
// Flush the stdout and stderror to show the print output.
17+
fflush(stdout)
18+
fflush(stderr)
19+
}
20+
1421
func testFilterResetIdle() {
1522
let filterName = "reset_idle_test_filter"
1623

mobile/test/swift/integration/GRPCReceiveErrorTest.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ final class GRPCReceiveErrorTests: XCTestCase {
1111
register_test_extensions()
1212
}
1313

14+
override static func tearDown() {
15+
super.tearDown()
16+
// Flush the stdout and stderror to show the print output.
17+
fflush(stdout)
18+
fflush(stderr)
19+
}
20+
1421
func testReceiveError() {
1522
let filterName = "error_validation_filter"
1623

mobile/test/swift/integration/IdleTimeoutTest.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ final class IdleTimeoutTests: XCTestCase {
1111
register_test_extensions()
1212
}
1313

14+
override static func tearDown() {
15+
super.tearDown()
16+
// Flush the stdout and stderror to show the print output.
17+
fflush(stdout)
18+
fflush(stderr)
19+
}
20+
1421
func testIdleTimeout() {
1522
let filterName = "reset_idle_test_filter"
1623

mobile/test/swift/integration/KeyValueStoreTest.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ final class KeyValueStoreTests: XCTestCase {
1111
register_test_extensions()
1212
}
1313

14+
override static func tearDown() {
15+
super.tearDown()
16+
// Flush the stdout and stderror to show the print output.
17+
fflush(stdout)
18+
fflush(stderr)
19+
}
20+
1421
func testKeyValueStore() {
1522
// swiftlint:disable:next line_length
1623
let kvStoreType = "type.googleapis.com/envoymobile.extensions.filters.http.test_kv_store.TestKeyValueStore"

mobile/test/swift/integration/ReceiveDataTest.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ final class ReceiveDataTests: XCTestCase {
1111
register_test_extensions()
1212
}
1313

14+
override static func tearDown() {
15+
super.tearDown()
16+
// Flush the stdout and stderror to show the print output.
17+
fflush(stdout)
18+
fflush(stderr)
19+
}
20+
1421
func testReceiveData() {
1522
let directResponseBody = "response_body"
1623
EnvoyTestServer.startHttp1PlaintextServer()

mobile/test/swift/integration/ReceiveErrorTest.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ final class ReceiveErrorTests: XCTestCase {
1010
register_test_extensions()
1111
}
1212

13+
override static func tearDown() {
14+
super.tearDown()
15+
// Flush the stdout and stderror to show the print output.
16+
fflush(stdout)
17+
fflush(stderr)
18+
}
19+
1320
func testReceiveError() {
1421
let filterName = "error_validation_filter"
1522

@@ -59,9 +66,6 @@ final class ReceiveErrorTests: XCTestCase {
5966
.setLogger { _, msg in
6067
print(msg, terminator: "")
6168
}
62-
.setLogger { _, msg in
63-
print(msg, terminator: "")
64-
}
6569
.addPlatformFilter(
6670
name: filterName,
6771
factory: {

0 commit comments

Comments
 (0)