From 1c2ffb9b30d01b87b693793cfa57ef22436f8917 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Wed, 10 Apr 2024 14:53:52 -0700 Subject: [PATCH] [Engine] allow --enable-asserts flag to be passed to dart vm in profile mode. (flutter/engine#52029) Allows https://github.com/flutter/flutter/issues/145729 --- engine/src/flutter/shell/common/switches.cc | 1 + engine/src/flutter/shell/common/switches_unittests.cc | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/engine/src/flutter/shell/common/switches.cc b/engine/src/flutter/shell/common/switches.cc index 40a4fd55650..c19f14fd713 100644 --- a/engine/src/flutter/shell/common/switches.cc +++ b/engine/src/flutter/shell/common/switches.cc @@ -65,6 +65,7 @@ static const std::string kAllowedDartFlags[] = { "--null_assertions", "--strict_null_safety_checks", "--max_subtype_cache_entries", + "--enable-asserts", }; // clang-format on diff --git a/engine/src/flutter/shell/common/switches_unittests.cc b/engine/src/flutter/shell/common/switches_unittests.cc index 617c0a891cf..b4494a29681 100644 --- a/engine/src/flutter/shell/common/switches_unittests.cc +++ b/engine/src/flutter/shell/common/switches_unittests.cc @@ -123,6 +123,16 @@ TEST(SwitchesTest, NoEnableImpeller) { } } +#if !FLUTTER_RELEASE +TEST(SwitchesTest, EnableAsserts) { + fml::CommandLine command_line = fml::CommandLineFromInitializerList( + {"command", "--dart-flags=--enable-asserts"}); + Settings settings = SettingsFromCommandLine(command_line); + ASSERT_EQ(settings.dart_flags.size(), 1ul); + EXPECT_EQ(settings.dart_flags[0], "--enable-asserts"); +} +#endif + } // namespace testing } // namespace flutter