Add a flag to sky_shell that keeps the process alive after the Dart script completes (flutter/engine#3363)
This commit is contained in:
@@ -82,6 +82,10 @@ DEF_SWITCH(UseTestFonts,
|
||||
"will make font resolution default to the Ahem test font on all "
|
||||
"platforms (See https://www.w3.org/Style/CSS/Test/Fonts/Ahem/). "
|
||||
"This option is only available on the desktop test shells.")
|
||||
DEF_SWITCH(RunForever,
|
||||
"run-forever",
|
||||
"In non-interactive mode, keep the shell running after the Dart "
|
||||
"script has completed.")
|
||||
DEF_SWITCHES_END
|
||||
|
||||
void PrintUsage(const std::string& executable_name);
|
||||
|
||||
@@ -43,7 +43,7 @@ class ScriptCompletionTaskObserver : public base::MessageLoop::TaskObserver {
|
||||
bool prev_live_;
|
||||
};
|
||||
|
||||
void RunNonInteractive() {
|
||||
void RunNonInteractive(bool run_forever) {
|
||||
base::MessageLoop message_loop;
|
||||
|
||||
shell::Shell::InitStandalone();
|
||||
@@ -51,9 +51,11 @@ void RunNonInteractive() {
|
||||
// Note that this task observer must be added after the observer that drains
|
||||
// the microtask queue.
|
||||
ScriptCompletionTaskObserver task_observer(message_loop);
|
||||
blink::Threads::UI()->PostTask([&task_observer] {
|
||||
base::MessageLoop::current()->AddTaskObserver(&task_observer);
|
||||
});
|
||||
if (!run_forever) {
|
||||
blink::Threads::UI()->PostTask([&task_observer] {
|
||||
base::MessageLoop::current()->AddTaskObserver(&task_observer);
|
||||
});
|
||||
}
|
||||
|
||||
if (!shell::InitForTesting()) {
|
||||
shell::PrintUsage("sky_shell");
|
||||
@@ -133,7 +135,9 @@ int main(int argc, const char* argv[]) {
|
||||
|
||||
if (command_line.HasSwitch(
|
||||
shell::FlagForSwitch(shell::Switch::NonInteractive))) {
|
||||
RunNonInteractive();
|
||||
bool run_forever = command_line.HasSwitch(
|
||||
shell::FlagForSwitch(shell::Switch::RunForever));
|
||||
RunNonInteractive(run_forever);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ class ShellLauncher {
|
||||
final List<String> args = [
|
||||
'--observatory-port=0',
|
||||
'--non-interactive',
|
||||
'--run-forever',
|
||||
];
|
||||
final String shellExecutablePath;
|
||||
final String mainDartPath;
|
||||
|
||||
Reference in New Issue
Block a user