Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_34031325
engine
提交
dd6f46c4
E
engine
项目概览
qq_34031325
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dd6f46c4
编写于
3月 26, 2018
作者:
R
Ryan Macnak
提交者:
Siva
3月 26, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make flutter_test on Mac exit on error like Linux and Windows. (#4873)
上级
a80905b5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
80 addition
and
1 deletion
+80
-1
shell/platform/darwin/desktop/main_mac.mm
shell/platform/darwin/desktop/main_mac.mm
+80
-1
未找到文件。
shell/platform/darwin/desktop/main_mac.mm
浏览文件 @
dd6f46c4
...
...
@@ -7,13 +7,69 @@
#include <iostream>
#include "flutter/fml/message_loop.h"
#include "flutter/shell/common/platform_view.h"
#include "flutter/shell/common/shell.h"
#include "flutter/shell/common/switches.h"
#include "flutter/shell/platform/darwin/common/platform_mac.h"
#include "flutter/shell/platform/darwin/desktop/flutter_application.h"
#include "flutter/shell/testing/test_runner.h"
#include "flutter/shell/testing/testing.h"
#include "lib/fxl/command_line.h"
#include "lib/fxl/logging.h"
#include "lib/tonic/dart_microtask_queue.h"
// Exit codes used by the Dart command line tool.
const
int
kApiErrorExitCode
=
253
;
const
int
kCompilationErrorExitCode
=
254
;
const
int
kErrorExitCode
=
255
;
// Checks whether the engine's main Dart isolate has no pending work. If so,
// then exit the given message loop.
class
ScriptCompletionTaskObserver
:
public
fml
::
TaskObserver
{
public:
ScriptCompletionTaskObserver
(
fxl
::
RefPtr
<
fxl
::
TaskRunner
>
task_runner
)
:
main_task_runner_
(
std
::
move
(
task_runner
)),
prev_live_
(
false
),
last_error_
(
tonic
::
kNoError
)
{}
void
DidProcessTask
()
override
{
shell
::
TestRunner
&
test_runner
=
shell
::
TestRunner
::
Shared
();
shell
::
Engine
&
engine
=
test_runner
.
platform_view
().
engine
();
if
(
engine
.
GetLoadScriptError
()
!=
tonic
::
kNoError
)
{
last_error_
=
engine
.
GetLoadScriptError
();
main_task_runner_
->
PostTask
([]()
{
fml
::
MessageLoop
::
GetCurrent
().
Terminate
();
});
return
;
}
bool
live
=
engine
.
UIIsolateHasLivePorts
();
if
(
prev_live_
&&
!
live
)
{
last_error_
=
engine
.
GetUIIsolateLastError
();
main_task_runner_
->
PostTask
([]()
{
fml
::
MessageLoop
::
GetCurrent
().
Terminate
();
});
}
prev_live_
=
live
;
}
tonic
::
DartErrorHandleType
last_error
()
{
return
last_error_
;
}
private:
fxl
::
RefPtr
<
fxl
::
TaskRunner
>
main_task_runner_
;
bool
prev_live_
;
tonic
::
DartErrorHandleType
last_error_
;
};
int
ConvertErrorTypeToExitCode
(
tonic
::
DartErrorHandleType
error
)
{
switch
(
error
)
{
case
tonic
::
kCompilationErrorType
:
return
kCompilationErrorExitCode
;
case
tonic
::
kApiErrorType
:
return
kApiErrorExitCode
;
case
tonic
::
kUnknownErrorType
:
return
kErrorExitCode
;
default:
return
0
;
}
}
static
fxl
::
CommandLine
InitializedCommandLine
()
{
std
::
vector
<
std
::
string
>
args_vector
;
...
...
@@ -47,8 +103,31 @@ int main(int argc, const char* argv[]) {
if
(
command_line
.
HasOption
(
shell
::
FlagForSwitch
(
shell
::
Switch
::
NonInteractive
)))
{
if
(
!
shell
::
InitForTesting
(
std
::
move
(
command_line
)))
return
1
;
// Note that this task observer must be added after the observer that drains
// the microtask queue.
ScriptCompletionTaskObserver
task_observer
(
fml
::
MessageLoop
::
GetCurrent
().
GetTaskRunner
());
blink
::
Threads
::
UI
()
->
PostTask
(
[
&
task_observer
]
{
fml
::
MessageLoop
::
GetCurrent
().
AddTaskObserver
(
&
task_observer
);
});
fml
::
MessageLoop
::
GetCurrent
().
Run
();
return
EXIT_SUCCESS
;
shell
::
TestRunner
&
test_runner
=
shell
::
TestRunner
::
Shared
();
tonic
::
DartErrorHandleType
error
=
test_runner
.
platform_view
().
engine
().
GetLoadScriptError
();
if
(
error
==
tonic
::
kNoError
)
error
=
task_observer
.
last_error
();
if
(
error
==
tonic
::
kNoError
)
{
fxl
::
AutoResetWaitableEvent
latch
;
blink
::
Threads
::
UI
()
->
PostTask
([
&
error
,
&
latch
]
{
error
=
tonic
::
DartMicrotaskQueue
::
GetForCurrentThread
()
->
GetLastError
();
latch
.
Signal
();
});
latch
.
Wait
();
}
// The script has completed and the engine may not be in a clean state,
// so just stop the process.
exit
(
ConvertErrorTypeToExitCode
(
error
));
}
else
{
return
NSApplicationMain
(
argc
,
argv
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录