From 8259f0a8bb65ab14eb1a435741866a6022d228b3 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Fri, 3 Feb 2017 12:14:35 -0800 Subject: [PATCH] Return the expected exit code if sky_shell sees a compilation error during script loading (flutter/engine#3389) --- engine/src/flutter/runtime/dart_controller.cc | 5 +++-- .../src/flutter/shell/platform/linux/main_linux.cc | 13 +++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/engine/src/flutter/runtime/dart_controller.cc b/engine/src/flutter/runtime/dart_controller.cc index 721bb9d214..43e7b3a3e7 100644 --- a/engine/src/flutter/runtime/dart_controller.cc +++ b/engine/src/flutter/runtime/dart_controller.cc @@ -129,8 +129,9 @@ tonic::DartErrorHandleType DartController::RunFromSource( Dart_Handle result = loader.LoadScript(main); LogIfError(result); tonic::DartErrorHandleType error = tonic::GetErrorHandleType(result); - if (SendStartMessage(Dart_RootLibrary())) - exit(1); + if (SendStartMessage(Dart_RootLibrary())) { + return tonic::kCompilationErrorType; + } return error; } diff --git a/engine/src/flutter/shell/platform/linux/main_linux.cc b/engine/src/flutter/shell/platform/linux/main_linux.cc index df9e49e48d..5ca105c554 100644 --- a/engine/src/flutter/shell/platform/linux/main_linux.cc +++ b/engine/src/flutter/shell/platform/linux/main_linux.cc @@ -40,9 +40,18 @@ class ScriptCompletionTaskObserver : public base::MessageLoop::TaskObserver { void DidProcessTask(const base::PendingTask& pending_task) override { shell::TestRunner& test_runner = shell::TestRunner::Shared(); - bool live = test_runner.platform_view().engine().UIIsolateHasLivePorts(); + shell::Engine& engine = test_runner.platform_view().engine(); + + if (engine.GetLoadScriptError() != tonic::kNoError) { + last_error_ = engine.GetLoadScriptError(); + main_message_loop_.PostTask(FROM_HERE, + main_message_loop_.QuitWhenIdleClosure()); + return; + } + + bool live = engine.UIIsolateHasLivePorts(); if (prev_live_ && !live) { - last_error_ = test_runner.platform_view().engine().GetUIIsolateLastError(); + last_error_ = engine.GetUIIsolateLastError(); main_message_loop_.PostTask(FROM_HERE, main_message_loop_.QuitWhenIdleClosure()); }