From 7e82588c317d56a1fd106efe9e5fa840ff805442 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Thu, 22 Aug 2024 15:40:10 -0700 Subject: [PATCH] Test running the macOS engine has no stray logging (flutter/engine#54716) Assert that running the macOS engine does not log anything unexpected See also issue https://github.com/flutter/flutter/issues/111577 Similar Windows check in https://github.com/flutter/engine/pull/47774 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- .../darwin/macos/framework/Source/FlutterEngineTest.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm index b7d8eb2311..7b7d4fb427 100644 --- a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm +++ b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm @@ -210,6 +210,7 @@ TEST_F(FlutterEngineTest, CanLogToStdout) { // Replace stdout stream buffer with our own. StreamCapture stdout_capture(&std::cout); + StreamCapture stderr_capture(&std::cerr); // Launch the test entrypoint. FlutterEngine* engine = GetFlutterEngine(); @@ -219,9 +220,12 @@ TEST_F(FlutterEngineTest, CanLogToStdout) { latch.Wait(); stdout_capture.Stop(); + stderr_capture.Stop(); // Verify hello world was written to stdout. - EXPECT_TRUE(stdout_capture.GetOutput().find("Hello logging") != std::string::npos); + // Check equality to ensure no unexpected stray logging. + EXPECT_EQ(stdout_capture.GetOutput(), "flutter: Hello logging\n"); + EXPECT_TRUE(stderr_capture.GetOutput().empty()); } TEST_F(FlutterEngineTest, DISABLED_BackgroundIsBlack) {