From 091739153596ec469158accabfa0f0567336095f Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Wed, 10 Apr 2024 12:21:12 -0700 Subject: [PATCH 1/4] [Engine] allow --enable-asserts flag to be passed to dart vm in profile mode. --- shell/common/switches.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/shell/common/switches.cc b/shell/common/switches.cc index 40a4fd5565072..c19f14fd71305 100644 --- a/shell/common/switches.cc +++ b/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 From 0212ab02aff62f8ea341ba09173856e57ac6e92c Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Wed, 10 Apr 2024 12:29:24 -0700 Subject: [PATCH 2/4] Add test. --- shell/common/switches_unittests.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/shell/common/switches_unittests.cc b/shell/common/switches_unittests.cc index 617c0a891cfa7..a7adc525de5d7 100644 --- a/shell/common/switches_unittests.cc +++ b/shell/common/switches_unittests.cc @@ -123,6 +123,18 @@ TEST(SwitchesTest, NoEnableImpeller) { } } +TEST(SwitchesTest, EnableAsserts) { + fml::CommandLine command_line = fml::CommandLineFromInitializerList( + {"command", "--dart-flags=--enable-asserts"}); + Settings settings = SettingsFromCommandLine(command_line); +#if !FLUTTER_RELEASE + ASSERT_EQ(settings.dart_flags.size(), 1ul); + EXPECT_EQ(settings.dart_flags[0], "--enable-asserts"); +#else + EXPECT_TRUE(settings.dart_flags.empty()); +#endif +} + } // namespace testing } // namespace flutter From d553fb02a2077c214aae3bc8ed2b08eaa4ef1291 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Wed, 10 Apr 2024 13:08:57 -0700 Subject: [PATCH 3/4] Update switches_unittests.cc --- shell/common/switches_unittests.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/shell/common/switches_unittests.cc b/shell/common/switches_unittests.cc index a7adc525de5d7..fc2ae2db5b60a 100644 --- a/shell/common/switches_unittests.cc +++ b/shell/common/switches_unittests.cc @@ -123,17 +123,15 @@ 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); -#if !FLUTTER_RELEASE ASSERT_EQ(settings.dart_flags.size(), 1ul); EXPECT_EQ(settings.dart_flags[0], "--enable-asserts"); -#else - EXPECT_TRUE(settings.dart_flags.empty()); -#endif } +#endif } // namespace testing } // namespace flutter From db6e0188536102dcbc0c7f2158b279f278f67101 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Wed, 10 Apr 2024 14:15:11 -0700 Subject: [PATCH 4/4] Update switches_unittests.cc --- shell/common/switches_unittests.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/common/switches_unittests.cc b/shell/common/switches_unittests.cc index fc2ae2db5b60a..b4494a2968170 100644 --- a/shell/common/switches_unittests.cc +++ b/shell/common/switches_unittests.cc @@ -131,7 +131,7 @@ TEST(SwitchesTest, EnableAsserts) { ASSERT_EQ(settings.dart_flags.size(), 1ul); EXPECT_EQ(settings.dart_flags[0], "--enable-asserts"); } -#endif +#endif } // namespace testing } // namespace flutter