Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
1401a60f
A
avocado
项目概览
openeuler
/
avocado
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
avocado
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1401a60f
编写于
11月 02, 2015
作者:
C
Cleber Rosa
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'ldoktor/exceptions3'
上级
8e833efe
422fbd68
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
76 addition
and
10 deletion
+76
-10
avocado/core/exit_codes.py
avocado/core/exit_codes.py
+2
-0
avocado/core/job.py
avocado/core/job.py
+4
-4
avocado/core/runner.py
avocado/core/runner.py
+15
-5
scripts/avocado
scripts/avocado
+55
-1
未找到文件。
avocado/core/exit_codes.py
浏览文件 @
1401a60f
...
...
@@ -37,3 +37,5 @@ AVOCADO_FAIL = 3
#: The job was explicitly interrupted. Usually this means that a user
#: hit CTRL+C while the job was still running.
AVOCADO_JOB_INTERRUPTED
=
4
#: Avocado generic crash
AVOCADO_GENERIC_CRASH
=
-
1
avocado/core/job.py
浏览文件 @
1401a60f
...
...
@@ -533,11 +533,11 @@ class Job(object):
except
exceptions
.
JobBaseException
,
details
:
self
.
status
=
details
.
status
fail_class
=
details
.
__class__
.
__name__
self
.
view
.
notify
(
event
=
'error'
,
msg
=
(
'
Avocado job failed: %s: %s'
%
(
fail_class
,
details
)))
self
.
view
.
notify
(
event
=
'error'
,
msg
=
(
'
\n
Avocado job failed: %s: %s'
%
(
fail_class
,
details
)))
return
exit_codes
.
AVOCADO_JOB_FAIL
except
exceptions
.
OptionValidationError
,
details
:
self
.
view
.
notify
(
event
=
'error'
,
msg
=
str
(
details
))
self
.
view
.
notify
(
event
=
'error'
,
msg
=
'
\n
'
+
str
(
details
))
return
exit_codes
.
AVOCADO_JOB_FAIL
except
Exception
,
details
:
...
...
@@ -546,7 +546,7 @@ class Job(object):
tb_info
=
traceback
.
format_exception
(
exc_type
,
exc_value
,
exc_traceback
.
tb_next
)
fail_class
=
details
.
__class__
.
__name__
self
.
view
.
notify
(
event
=
'error'
,
msg
=
(
'Avocado crashed: %s: %s'
%
self
.
view
.
notify
(
event
=
'error'
,
msg
=
(
'
\n
Avocado crashed: %s: %s'
%
(
fail_class
,
details
)))
for
line
in
tb_info
:
self
.
view
.
notify
(
event
=
'minor'
,
msg
=
line
)
...
...
avocado/core/runner.py
浏览文件 @
1401a60f
...
...
@@ -140,14 +140,24 @@ class TestRunner(object):
proc
.
start
()
end
=
time
.
time
()
+
10
while
queue
.
empty
():
if
not
proc
.
is_alive
()
and
queue
.
empty
():
raise
exceptions
.
TestError
(
"Process died before it pushed "
"early state."
)
if
time
.
time
()
>
end
:
msg
=
(
"Unable to receive test's early-state in 10s, "
"something wrong happened probably in the "
"avocado framework."
)
os
.
kill
(
proc
.
pid
,
9
)
raise
exceptions
.
TestError
(
msg
)
time
.
sleep
(
0
)
early_state
=
queue
.
get
()
if
'load_exception'
in
early_state
:
self
.
job
.
view
.
notify
(
event
=
'error'
,
msg
=
'Avocado crashed during test load. '
'Some reports might have not been '
'generated. Aborting...'
)
sys
.
exit
(
exit_codes
.
AVOCADO_FAIL
)
raise
exceptions
.
TestError
(
'Avocado crashed during test load. '
'Some reports might have not been '
'generated. Aborting...'
)
# At this point, the test is already initialized and we know
# for sure if there's a timeout set.
...
...
scripts/avocado
浏览文件 @
1401a60f
...
...
@@ -14,8 +14,62 @@
# Author: Lucas Meneghel Rodrigues <lmr@redhat.com>
import
os
import
sys
try
:
import
logging
import
os
import
tempfile
import
traceback
except
:
sys
.
stderr
.
write
(
"Unable to import basic python libraries, please "
"reinstall avocado and dependencies.
\n
"
)
# This exit code is replicated from avocado/core/exit_codes.py and not
# imported because we are dealing with import failures
sys
.
exit
(
-
1
)
def
handle_exception
(
*
exc_info
):
# Print traceback into avocado.app.traceback if initialized
msg
=
"Avocado crashed:
\n
"
+
""
.
join
(
traceback
.
format_exception
(
*
exc_info
))
log
=
logging
.
getLogger
(
"avocado.app.tracebacks"
)
if
getattr
(
log
,
"handlers"
,
False
):
log
.
error
(
msg
)
# Store traceback in data_dir or TMPDIR
crash_dir
=
None
prefix
=
"avocado-traceback-"
try
:
import
time
prefix
+=
time
.
strftime
(
"%F_%T"
)
+
"-"
from
avocado.core
import
data_dir
_crash_dir
=
os
.
path
.
join
(
data_dir
.
get_data_dir
(),
"crashes"
)
os
.
makedirs
(
_crash_dir
)
crash_dir
=
_crash_dir
except
:
pass
tmp
,
name
=
tempfile
.
mkstemp
(
".log"
,
prefix
,
crash_dir
)
os
.
write
(
tmp
,
msg
)
os
.
close
(
tmp
)
# Print friendly message in console-like output
msg
=
(
"Avocado crashed unexpectidly: %s
\n
You can find details in %s"
%
(
exc_info
[
1
],
name
))
for
name
in
(
"avocado.app"
,
"avocado.test"
,
None
):
log
=
logging
.
getLogger
(
name
)
for
handler
in
getattr
(
log
,
"handlers"
,
[]):
if
isinstance
(
handler
,
logging
.
StreamHandler
):
break
else
:
continue
log
.
critical
(
msg
)
break
else
:
# Log not found, use stderr and hope it's enabled
sys
.
stderr
.
write
(
msg
+
'
\n
'
)
# This exit code is replicated from avocado/core/exit_codes.py and not
# imported because we are dealing with import failures
sys
.
exit
(
-
1
)
if
__name__
==
'__main__'
:
sys
.
excepthook
=
handle_exception
# simple magic for using scripts within a source tree
basedir
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录