Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Add --enable-isolate-groups to allowed flags in switches.cc #21149

Merged
merged 3 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 33 additions & 32 deletions shell/common/shell_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,30 @@ static void ValidateDestroyPlatformView(Shell* shell) {
ASSERT_FALSE(RasterizerHasLayerTree(shell));
}

static std::string CreateFlagsString(std::vector<const char*>& flags) {
if (flags.size() == 0) {
return "";
}
std::string flags_string = flags[0];
for (size_t i = 1; i < flags.size(); ++i) {
flags_string += ",";
flags_string += flags[i];
}
return flags_string;
}

static void TestDartVmFlags(std::vector<const char*>& flags) {
std::string flags_string = CreateFlagsString(flags);
const std::vector<fml::CommandLine::Option> options = {
fml::CommandLine::Option("dart-flags", flags_string)};
fml::CommandLine command_line("", options, std::vector<std::string>());
flutter::Settings settings = flutter::SettingsFromCommandLine(command_line);
EXPECT_EQ(settings.dart_flags.size(), flags.size());
for (size_t i = 0; i < flags.size(); ++i) {
EXPECT_EQ(settings.dart_flags[i], flags[i]);
}
}

TEST_F(ShellTest, InitializeWithInvalidThreads) {
ASSERT_FALSE(DartVMRef::IsInstanceRunning());
Settings settings = CreateSettingsForFixture();
Expand Down Expand Up @@ -275,25 +299,6 @@ TEST_F(ShellTest, LastEntrypoint) {
ASSERT_FALSE(DartVMRef::IsInstanceRunning());
}

TEST(ShellTestNoFixture, EnableMirrorsIsAllowed) {
if (DartVM::IsRunningPrecompiledCode()) {
// This covers profile and release modes which use AOT (where this flag does
// not make sense anyway).
GTEST_SKIP();
return;
}
#if FLUTTER_RELEASE
GTEST_SKIP();
return;
#endif

const std::vector<fml::CommandLine::Option> options = {
fml::CommandLine::Option("dart-flags", "--enable_mirrors")};
fml::CommandLine command_line("", options, std::vector<std::string>());
flutter::Settings settings = flutter::SettingsFromCommandLine(command_line);
EXPECT_EQ(settings.dart_flags.size(), 1u);
}

TEST_F(ShellTest, DisallowedDartVMFlag) {
// Run this test in a thread-safe manner, otherwise gtest will complain.
::testing::FLAGS_gtest_death_test_style = "threadsafe";
Expand All @@ -309,22 +314,18 @@ TEST_F(ShellTest, DisallowedDartVMFlag) {
}

TEST_F(ShellTest, AllowedDartVMFlag) {
const std::vector<fml::CommandLine::Option> options = {
#if !FLUTTER_RELEASE
fml::CommandLine::Option("dart-flags",
"--max_profile_depth 1,--random_seed 42")
#endif
std::vector<const char*> flags = {
"--enable-isolate-groups",
"--no-enable-isolate-groups",
};
fml::CommandLine command_line("", options, std::vector<std::string>());
flutter::Settings settings = flutter::SettingsFromCommandLine(command_line);

#if !FLUTTER_RELEASE
EXPECT_EQ(settings.dart_flags.size(), 2u);
EXPECT_EQ(settings.dart_flags[0], "--max_profile_depth 1");
EXPECT_EQ(settings.dart_flags[1], "--random_seed 42");
#else
EXPECT_EQ(settings.dart_flags.size(), 0u);
flags.push_back("--max_profile_depth 1");
flags.push_back("--random_seed 42");
if (!DartVM::IsRunningPrecompiledCode()) {
flags.push_back("--enable_mirrors");
}
#endif
TestDartVmFlags(flags);
}

TEST_F(ShellTest, NoNeedToReportTimingsByDefault) {
Expand Down
4 changes: 4 additions & 0 deletions shell/common/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ struct SwitchDesc {

// clang-format off
static const std::string gAllowedDartFlags[] = {
"--enable-isolate-groups",
"--no-enable-isolate-groups",
"--no-causal_async_stacks",
"--lazy_async_stacks",
};
Expand All @@ -51,6 +53,8 @@ static const std::string gAllowedDartFlags[] = {

// clang-format off
static const std::string gAllowedDartFlags[] = {
"--enable-isolate-groups",
"--no-enable-isolate-groups",
"--enable_mirrors",
"--enable-service-port-fallback",
"--lazy_async_stacks",
Expand Down