Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
0ca04fc9
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,发现更多精彩内容 >>
提交
0ca04fc9
编写于
12月 15, 2015
作者:
C
Cleber Rosa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Plugins: port JSON plugin
Signed-off-by:
N
Cleber Rosa
<
crosa@redhat.com
>
上级
d396ccd5
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
51 addition
and
47 deletion
+51
-47
avocado/core/job.py
avocado/core/job.py
+1
-1
avocado/core/jsonresult.py
avocado/core/jsonresult.py
+2
-29
avocado/plugins/json.py
avocado/plugins/json.py
+46
-0
selftests/functional/test_basic.py
selftests/functional/test_basic.py
+0
-10
selftests/functional/test_output.py
selftests/functional/test_output.py
+0
-6
selftests/unit/test_jsonresult.py
selftests/unit/test_jsonresult.py
+1
-1
setup.py
setup.py
+1
-0
未找到文件。
avocado/core/job.py
浏览文件 @
0ca04fc9
...
...
@@ -41,8 +41,8 @@ from . import multiplexer
from
.
import
tree
from
.
import
test
from
.
import
xunit
from
.
import
jsonresult
from
.settings
import
settings
from
.plugins
import
jsonresult
from
..utils
import
archive
from
..utils
import
astring
from
..utils
import
path
...
...
avocado/core/
plugins/
jsonresult.py
→
avocado/core/jsonresult.py
浏览文件 @
0ca04fc9
...
...
@@ -18,9 +18,8 @@ JSON output module.
import
json
from
.
import
plugin
from
..
import
output
from
..result
import
TestResult
from
.
import
output
from
.result
import
TestResult
class
JSONTestResult
(
TestResult
):
...
...
@@ -89,29 +88,3 @@ class JSONTestResult(TestResult):
self
.
view
.
notify
(
event
=
'minor'
,
msg
=
self
.
json
)
else
:
self
.
_save_json
()
class
JSON
(
plugin
.
Plugin
):
"""
JSON output
"""
name
=
'json'
enabled
=
True
def
configure
(
self
,
parser
):
self
.
parser
=
parser
self
.
parser
.
runner
.
output
.
add_argument
(
'--json'
,
type
=
str
,
dest
=
'json_output'
,
metavar
=
'FILE'
,
help
=
'Enable JSON result format and write it to FILE. '
"Use '-' to redirect to the standard output."
)
self
.
configured
=
True
def
activate
(
self
,
app_args
):
try
:
if
app_args
.
json_output
:
self
.
parser
.
application
.
set_defaults
(
json_result
=
JSONTestResult
)
except
AttributeError
:
pass
avocado/plugins/json.py
0 → 100644
浏览文件 @
0ca04fc9
# 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. 2014
# Author: Ruda Moura <rmoura@redhat.com>
"""
JSON output module.
"""
from
avocado.core.jsonresult
import
JSONTestResult
from
.base
import
CLI
class
JSON
(
CLI
):
"""
JSON output
"""
name
=
'json'
description
=
"JSON output options for 'run' command"
def
configure
(
self
,
parser
):
run_subcommand_parser
=
parser
.
subcommands
.
choices
.
get
(
'run'
,
None
)
if
run_subcommand_parser
is
None
:
return
run_subcommand_parser
.
output
.
add_argument
(
'--json'
,
type
=
str
,
dest
=
'json_output'
,
metavar
=
'FILE'
,
help
=
'Enable JSON result format and write it to FILE. '
"Use '-' to redirect to the standard output."
)
def
run
(
self
,
args
):
if
'json_output'
in
args
and
args
.
json_output
is
not
None
:
args
.
json_result
=
JSONTestResult
selftests/functional/test_basic.py
浏览文件 @
0ca04fc9
...
...
@@ -120,7 +120,6 @@ class RunnerOperationTest(unittest.TestCase):
output
,
"Test did not fail with action exception:
\n
%s"
%
output
)
@
unittest
.
skip
(
"Temporary plugin infrastructure removal"
)
def
test_uncaught_exception
(
self
):
os
.
chdir
(
basedir
)
cmd_line
=
(
"./scripts/avocado run --sysinfo=off --job-results-dir %s "
...
...
@@ -132,7 +131,6 @@ class RunnerOperationTest(unittest.TestCase):
result
))
self
.
assertIn
(
'"status": "ERROR"'
,
result
.
stdout
)
@
unittest
.
skip
(
"Temporary plugin infrastructure removal"
)
def
test_fail_on_exception
(
self
):
os
.
chdir
(
basedir
)
cmd_line
=
(
"./scripts/avocado run --sysinfo=off --job-results-dir %s "
...
...
@@ -225,7 +223,6 @@ class RunnerOperationTest(unittest.TestCase):
self
.
assertNotIn
(
'needs to be a 40 digit hex'
,
result
.
stderr
)
self
.
assertIn
(
'PASS'
,
result
.
stdout
)
@
unittest
.
skip
(
"Temporary plugin infrastructure removal"
)
def
test_automatic_unique_id
(
self
):
cmd_line
=
'./scripts/avocado run --job-results-dir %s --sysinfo=off passtest --json -'
%
self
.
tmpdir
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
)
...
...
@@ -234,7 +231,6 @@ class RunnerOperationTest(unittest.TestCase):
int
(
r
[
'job_id'
],
16
)
# it's an hex number
self
.
assertEqual
(
len
(
r
[
'job_id'
]),
40
)
@
unittest
.
skip
(
"Temporary plugin infrastructure removal"
)
def
test_skip_outside_setup
(
self
):
os
.
chdir
(
basedir
)
cmd_line
=
(
"./scripts/avocado run --sysinfo=off --job-results-dir %s "
...
...
@@ -264,7 +260,6 @@ class RunnerOperationTest(unittest.TestCase):
self
.
assertTrue
(
os
.
path
.
exists
(
link
))
self
.
assertTrue
(
os
.
path
.
islink
(
link
))
@
unittest
.
skip
(
"Temporary plugin infrastructure removal"
)
def
test_dry_run
(
self
):
os
.
chdir
(
basedir
)
cmd
=
(
"./scripts/avocado run --sysinfo=off passtest failtest "
...
...
@@ -729,27 +724,22 @@ class PluginsJSONTest(AbsPluginsTest, unittest.TestCase):
"Different number of skipped tests"
)
return
json_data
@
unittest
.
skip
(
"Temporary plugin infrastructure removal"
)
def
test_json_plugin_passtest
(
self
):
self
.
run_and_check
(
'passtest'
,
exit_codes
.
AVOCADO_ALL_OK
,
1
,
0
,
0
,
0
)
@
unittest
.
skip
(
"Temporary plugin infrastructure removal"
)
def
test_json_plugin_failtest
(
self
):
self
.
run_and_check
(
'failtest'
,
exit_codes
.
AVOCADO_TESTS_FAIL
,
1
,
0
,
1
,
0
)
@
unittest
.
skip
(
"Temporary plugin infrastructure removal"
)
def
test_json_plugin_skiponsetuptest
(
self
):
self
.
run_and_check
(
'skiponsetup'
,
exit_codes
.
AVOCADO_ALL_OK
,
1
,
0
,
0
,
1
)
@
unittest
.
skip
(
"Temporary plugin infrastructure removal"
)
def
test_json_plugin_errortest
(
self
):
self
.
run_and_check
(
'errortest'
,
exit_codes
.
AVOCADO_TESTS_FAIL
,
1
,
1
,
0
,
0
)
@
unittest
.
skip
(
"Temporary plugin infrastructure removal"
)
def
test_ugly_echo_cmd
(
self
):
if
not
os
.
path
.
exists
(
"/bin/echo"
):
self
.
skipTest
(
"Program /bin/echo does not exist"
)
...
...
selftests/functional/test_output.py
浏览文件 @
0ca04fc9
...
...
@@ -65,7 +65,6 @@ class OutputPluginTest(unittest.TestCase):
self
.
assertTrue
(
os
.
path
.
isfile
(
json_output
))
minidom
.
parse
(
xunit_output
)
@
unittest
.
skip
(
"Temporary plugin infrastructure removal"
)
def
test_output_incompatible_setup
(
self
):
os
.
chdir
(
basedir
)
cmd_line
=
'./scripts/avocado run --job-results-dir %s --sysinfo=off --xunit - --json - passtest'
%
self
.
tmpdir
...
...
@@ -93,7 +92,6 @@ class OutputPluginTest(unittest.TestCase):
self
.
assertIn
(
error_excerpt
,
output
,
"Missing excerpt error message from output:
\n
%s"
%
output
)
@
unittest
.
skip
(
"Temporary plugin infrastructure removal"
)
def
test_output_compatible_setup
(
self
):
tmpfile
=
tempfile
.
mktemp
()
os
.
chdir
(
basedir
)
...
...
@@ -115,7 +113,6 @@ class OutputPluginTest(unittest.TestCase):
except
OSError
:
pass
@
unittest
.
skip
(
"Temporary plugin infrastructure removal"
)
def
test_output_compatible_setup_2
(
self
):
tmpfile
=
tempfile
.
mktemp
()
os
.
chdir
(
basedir
)
...
...
@@ -174,7 +171,6 @@ class OutputPluginTest(unittest.TestCase):
except
OSError
:
pass
@
unittest
.
skip
(
"Temporary plugin infrastructure removal"
)
def
test_output_compatible_setup_nooutput
(
self
):
tmpfile
=
tempfile
.
mktemp
()
tmpfile2
=
tempfile
.
mktemp
()
...
...
@@ -248,7 +244,6 @@ class OutputPluginTest(unittest.TestCase):
debug_log
=
second_line
.
split
()[
-
1
]
self
.
check_output_files
(
debug_log
)
@
unittest
.
skip
(
"Temporary plugin infrastructure removal"
)
def
test_verify_whiteboard_save
(
self
):
tmpfile
=
tempfile
.
mktemp
()
try
:
...
...
@@ -273,7 +268,6 @@ class OutputPluginTest(unittest.TestCase):
except
OSError
:
pass
@
unittest
.
skip
(
"Temporary plugin infrastructure removal"
)
@
unittest
.
skipIf
(
image_output_uncapable
(),
"Uncapable of generating images with PIL library"
)
def
test_gendata
(
self
):
...
...
selftests/unit/test_jsonresult.py
浏览文件 @
0ca04fc9
...
...
@@ -6,7 +6,7 @@ import tempfile
import
shutil
from
avocado
import
Test
from
avocado.core
.plugins
import
jsonresult
from
avocado.core
import
jsonresult
from
avocado.core
import
job
...
...
setup.py
浏览文件 @
0ca04fc9
...
...
@@ -130,6 +130,7 @@ if __name__ == '__main__':
'gdb = avocado.plugins.gdb:GDB'
,
'wrapper = avocado.plugins.wrapper:Wrapper'
,
'xunit = avocado.plugins.xunit:XUnit'
,
'json = avocado.plugins.json:JSON'
,
],
'avocado.plugins.cli.cmd'
:
[
'config = avocado.plugins.config:Config'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录