Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
2e6ecce6
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,发现更多精彩内容 >>
提交
2e6ecce6
编写于
11月 04, 2016
作者:
C
Cleber Rosa
提交者:
Lukáš Doktor
11月 04, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Result: make human UI a ResultEvents plugin
Signed-off-by:
N
Cleber Rosa
<
crosa@redhat.com
>
上级
74ea1680
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
103 addition
and
83 deletion
+103
-83
avocado/core/job.py
avocado/core/job.py
+0
-4
avocado/core/result.py
avocado/core/result.py
+0
-79
avocado/plugins/human.py
avocado/plugins/human.py
+100
-0
setup.py
setup.py
+3
-0
未找到文件。
avocado/core/job.py
浏览文件 @
2e6ecce6
...
...
@@ -285,10 +285,6 @@ class Job(object):
test_result_instance
=
klass
(
self
)
self
.
result_proxy
.
add_output_plugin
(
test_result_instance
)
if
not
getattr
(
self
.
args
,
'stdout_claimed_by'
,
False
)
or
self
.
standalone
:
human_plugin
=
result
.
HumanResult
(
self
)
self
.
result_proxy
.
add_output_plugin
(
human_plugin
)
if
not
self
.
result_proxy
.
output_plugins
:
self
.
result_proxy
.
add_output_plugin
(
result
.
Result
(
self
))
...
...
avocado/core/result.py
浏览文件 @
2e6ecce6
...
...
@@ -15,15 +15,8 @@
"""
Contains the definition of the Result class, used for output in avocado.
It also contains the most basic result class, HumanResult, used by the
test runner.
"""
import
logging
from
.
import
output
class
InvalidOutputPlugin
(
Exception
):
pass
...
...
@@ -180,75 +173,3 @@ class Result(object):
else
:
self
.
errors
+=
1
self
.
end_test
(
state
)
class
HumanResult
(
Result
):
"""
Human output Test result class.
"""
def
__init__
(
self
,
job
):
super
(
HumanResult
,
self
).
__init__
(
job
)
self
.
log
=
logging
.
getLogger
(
"avocado.app"
)
self
.
__throbber
=
output
.
Throbber
()
self
.
_replay_source_job
=
getattr
(
job
.
args
,
"replay_sourcejob"
,
None
)
def
start_tests
(
self
):
"""
Called once before any tests are executed.
"""
super
(
HumanResult
,
self
).
start_tests
()
self
.
log
.
info
(
"JOB ID : %s"
,
self
.
job_unique_id
)
if
self
.
_replay_source_job
is
not
None
:
self
.
log
.
info
(
"SRC JOB ID : %s"
,
self
.
_replay_source_job
)
self
.
log
.
info
(
"JOB LOG : %s"
,
self
.
logfile
)
self
.
log
.
info
(
"TESTS : %s"
,
self
.
tests_total
)
def
end_tests
(
self
):
"""
Called once after all tests are executed.
"""
super
(
HumanResult
,
self
).
end_tests
()
self
.
log
.
info
(
"RESULTS : PASS %d | ERROR %d | FAIL %d | SKIP %d | "
"WARN %d | INTERRUPT %s"
,
self
.
passed
,
self
.
errors
,
self
.
failed
,
self
.
skipped
,
self
.
warned
,
self
.
interrupted
)
self
.
log
.
info
(
"TESTS TIME : %.2f s"
,
self
.
tests_total_time
)
def
start_test
(
self
,
state
):
super
(
HumanResult
,
self
).
start_test
(
state
)
if
"name"
in
state
:
name
=
state
[
"name"
]
uid
=
name
.
str_uid
name
=
name
.
name
+
name
.
str_variant
else
:
name
=
"<unknown>"
uid
=
'?'
self
.
log
.
debug
(
' (%s/%s) %s: '
,
uid
,
self
.
tests_total
,
name
,
extra
=
{
"skip_newline"
:
True
})
def
end_test
(
self
,
state
):
super
(
HumanResult
,
self
).
end_test
(
state
)
status
=
state
.
get
(
"status"
,
"ERROR"
)
if
status
==
"TEST_NA"
:
status
=
"SKIP"
mapping
=
{
'PASS'
:
output
.
TERM_SUPPORT
.
PASS
,
'ERROR'
:
output
.
TERM_SUPPORT
.
ERROR
,
'FAIL'
:
output
.
TERM_SUPPORT
.
FAIL
,
'SKIP'
:
output
.
TERM_SUPPORT
.
SKIP
,
'WARN'
:
output
.
TERM_SUPPORT
.
WARN
,
'INTERRUPTED'
:
output
.
TERM_SUPPORT
.
INTERRUPT
}
duration
=
(
" (%.2f s)"
%
state
.
get
(
'time_elapsed'
,
-
1
)
if
status
!=
"SKIP"
else
""
)
self
.
log
.
debug
(
output
.
TERM_SUPPORT
.
MOVE_BACK
+
mapping
[
status
]
+
status
+
output
.
TERM_SUPPORT
.
ENDC
+
duration
)
def
notify_progress
(
self
,
progress
=
False
):
if
progress
:
color
=
output
.
TERM_SUPPORT
.
PASS
else
:
color
=
output
.
TERM_SUPPORT
.
PARTIAL
self
.
log
.
debug
(
color
+
self
.
__throbber
.
render
()
+
output
.
TERM_SUPPORT
.
ENDC
,
extra
=
{
"skip_newline"
:
True
})
avocado/plugins/human.py
0 → 100644
浏览文件 @
2e6ecce6
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See LICENSE for more details.
#
# Copyright: Red Hat, Inc. 2016
# Author: Cleber Rosa <crosa@redhat.com>
"""
Human result UI
"""
import
logging
from
avocado.core.plugin_interfaces
import
ResultEvents
from
avocado.core
import
output
class
Human
(
ResultEvents
):
"""
Human result UI
"""
name
=
'human'
description
=
"Human Interface UI"
output_mapping
=
{
'PASS'
:
output
.
TERM_SUPPORT
.
PASS
,
'ERROR'
:
output
.
TERM_SUPPORT
.
ERROR
,
'FAIL'
:
output
.
TERM_SUPPORT
.
FAIL
,
'SKIP'
:
output
.
TERM_SUPPORT
.
SKIP
,
'WARN'
:
output
.
TERM_SUPPORT
.
WARN
,
'INTERRUPTED'
:
output
.
TERM_SUPPORT
.
INTERRUPT
}
def
__init__
(
self
,
args
):
self
.
log
=
logging
.
getLogger
(
"avocado.app"
)
self
.
__throbber
=
output
.
Throbber
()
stdout_claimed_by
=
getattr
(
args
,
'stdout_claimed_by'
,
None
)
self
.
owns_stdout
=
not
stdout_claimed_by
def
pre_tests
(
self
,
job
):
if
not
self
.
owns_stdout
:
return
self
.
log
.
info
(
"JOB ID : %s"
,
job
.
unique_id
)
replay_source_job
=
getattr
(
job
.
args
,
"replay_sourcejob"
,
False
)
if
replay_source_job
:
self
.
log
.
info
(
"SRC JOB ID : %s"
,
self
.
__replay_source_job
)
self
.
log
.
info
(
"JOB LOG : %s"
,
job
.
logfile
)
self
.
log
.
info
(
"TESTS : %s"
,
len
(
job
.
test_suite
))
def
start_test
(
self
,
result
,
state
):
if
not
self
.
owns_stdout
:
return
if
"name"
in
state
:
name
=
state
[
"name"
]
uid
=
name
.
str_uid
name
=
name
.
name
+
name
.
str_variant
else
:
name
=
"<unknown>"
uid
=
'?'
self
.
log
.
debug
(
' (%s/%s) %s: '
,
uid
,
result
.
tests_total
,
name
,
extra
=
{
"skip_newline"
:
True
})
def
test_progress
(
self
,
progress
=
False
):
if
not
self
.
owns_stdout
:
return
if
progress
:
color
=
output
.
TERM_SUPPORT
.
PASS
else
:
color
=
output
.
TERM_SUPPORT
.
PARTIAL
self
.
log
.
debug
(
color
+
self
.
__throbber
.
render
()
+
output
.
TERM_SUPPORT
.
ENDC
,
extra
=
{
"skip_newline"
:
True
})
def
end_test
(
self
,
result
,
state
):
if
not
self
.
owns_stdout
:
return
status
=
state
.
get
(
"status"
,
"ERROR"
)
if
status
==
"TEST_NA"
:
status
=
"SKIP"
duration
=
(
" (%.2f s)"
%
state
.
get
(
'time_elapsed'
,
-
1
)
if
status
!=
"SKIP"
else
""
)
self
.
log
.
debug
(
output
.
TERM_SUPPORT
.
MOVE_BACK
+
self
.
output_mapping
[
status
]
+
status
+
output
.
TERM_SUPPORT
.
ENDC
+
duration
)
def
post_tests
(
self
,
job
):
if
not
self
.
owns_stdout
:
return
self
.
log
.
info
(
"RESULTS : PASS %d | ERROR %d | FAIL %d | SKIP %d | "
"WARN %d | INTERRUPT %s"
,
job
.
result
.
passed
,
job
.
result
.
errors
,
job
.
result
.
failed
,
job
.
result
.
skipped
,
job
.
result
.
warned
,
job
.
result
.
interrupted
)
self
.
log
.
info
(
"TESTS TIME : %.2f s"
,
job
.
result
.
tests_total_time
)
setup.py
浏览文件 @
2e6ecce6
...
...
@@ -160,6 +160,9 @@ if __name__ == '__main__':
'json = avocado.plugins.jsonresult:JSONResult'
,
'zip_archive = avocado.plugins.archive:Archive'
,
],
'avocado.plugins.result_events'
:
[
'human = avocado.plugins.human:Human'
,
],
},
zip_safe
=
False
,
test_suite
=
'selftests'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录