Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_46011646
wechaty
提交
b16d0fa0
W
wechaty
项目概览
weixin_46011646
/
wechaty
与 Fork 源项目一致
Fork自
wechaty / wechaty
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
wechaty
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b16d0fa0
编写于
6月 21, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mute warn log for watchDogReset unit test
上级
3a5c8dc1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
6 deletion
+10
-6
src/puppet-web.js
src/puppet-web.js
+2
-2
test/puppet-web-spec.js
test/puppet-web-spec.js
+8
-4
未找到文件。
src/puppet-web.js
浏览文件 @
b16d0fa0
...
...
@@ -89,7 +89,7 @@ class PuppetWeb extends Puppet {
if
(
this
.
server
)
{
yield
this
.
server
.
quit
()
this
.
server
=
null
}
else
{
log
.
warn
(
'
PuppetWeb
'
,
'
quit() without a server
'
)
}
}
else
{
log
.
verbose
(
'
PuppetWeb
'
,
'
quit() without a server
'
)
}
if
(
this
.
browser
)
{
yield
(
this
.
browser
.
quit
().
catch
(
e
=>
{
// fail safe
...
...
@@ -230,7 +230,7 @@ class PuppetWeb extends Puppet {
}
watchDogReset
(
timeout
)
{
log
.
warn
(
'
PuppetWeb
'
,
'
watchDogReset() timeout %d
'
,
timeout
)
log
.
verbose
(
'
PuppetWeb
'
,
'
watchDogReset() timeout %d
'
,
timeout
)
const
e
=
new
Error
(
'
watchdog reset after
'
+
Math
.
floor
(
timeout
/
1000
)
+
'
seconds
'
)
this
.
emit
(
'
error
'
,
e
)
return
Event
.
onBrowserDead
.
call
(
this
,
e
)
...
...
test/puppet-web-spec.js
浏览文件 @
b16d0fa0
...
...
@@ -27,7 +27,6 @@ test('PuppetWeb smoke testing', function(t) {
m
.
set
(
'
from
'
,
EXPECTED_USER_ID
)
t
.
ok
(
pw
.
self
(
m
),
'
should identified self for message which from is self
'
)
// XXX find a better way to mock...
pw
.
bridge
.
getUserName
=
function
()
{
return
Promise
.
resolve
(
'
mockedUserName
'
)
}
pw
.
getContact
=
function
()
{
return
Promise
.
resolve
(
'
dummy
'
)
}
...
...
@@ -66,7 +65,7 @@ test('Puppet Web server/browser communication', function(t) {
let
pw
=
new
PuppetWeb
({
port
:
PORT
,
head
:
HEAD
,
session
:
SESSION
})
t
.
ok
(
pw
,
'
should instantiated a PuppetWeb
'
)
const
EXPECTED_DING_DATA
=
'
dingdong
'
const
EXPECTED_DING_DATA
=
'
dingdong
'
co
(
function
*
()
{
yield
pw
.
init
()
...
...
@@ -143,7 +142,12 @@ test('Puppet Web watchdog timer', function(t) {
const
EXPECTED_DING_DATA
=
'
dingdong
'
pw
.
watchDog
(
'
feed to extend the dog life
'
)
const
origLogLevel
=
log
.
level
log
.
level
=
'
silent
'
t
.
ok
(
'
set log.level = silent to mute log when watchDog reset wechaty
'
)
const
dong
=
yield
waitDing
(
EXPECTED_DING_DATA
)
log
.
level
=
origLogLevel
t
.
equal
(
dong
,
EXPECTED_DING_DATA
,
'
should get EXPECTED_DING_DATA from ding after watchdog reset
'
)
})
.
catch
(
e
=>
{
// Exception
...
...
@@ -166,7 +170,7 @@ test('Puppet Web watchdog timer', function(t) {
// timeout = 49,000 for {max: 7, backoff: 2000}
const
timeout
=
max
*
(
backoff
*
max
)
/
2
return
retryPromise
({
max
:
max
,
backoff
:
backoff
},
function
(
attempt
)
{
return
retryPromise
({
max
:
max
,
backoff
:
backoff
},
function
(
attempt
)
{
log
.
silly
(
'
TestPuppetWeb
'
,
'
waitDing() retryPromise: attampt %s/%s time for timeout %s
'
,
attempt
,
max
,
timeout
)
return
pw
.
ding
(
data
)
...
...
@@ -194,4 +198,4 @@ test('Puppet Web Self Message Identification', function(t) {
t
.
ok
(
p
,
'
should instantiated a PuppetWeb
'
)
t
.
end
()
})
\ No newline at end of file
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录