Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
e2151f76
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,发现更多精彩内容 >>
未验证
提交
e2151f76
编写于
9月 24, 2018
作者:
C
Cleber Rosa
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'cacarrara/moves-html-test-to-plugin'
Signed-off-by:
N
Cleber Rosa
<
crosa@redhat.com
>
上级
5c8bd0f4
9d3d46cf
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
78 addition
and
55 deletion
+78
-55
optional_plugins/html/tests/__init__.py
optional_plugins/html/tests/__init__.py
+0
-0
optional_plugins/html/tests/test_html_result.py
optional_plugins/html/tests/test_html_result.py
+78
-0
selftests/functional/test_output.py
selftests/functional/test_output.py
+0
-55
未找到文件。
optional_plugins/html/tests/__init__.py
0 → 100644
浏览文件 @
e2151f76
optional_plugins/html/tests/test_html_result.py
0 → 100644
浏览文件 @
e2151f76
import
json
import
os
import
shutil
import
tempfile
import
unittest
from
xml.dom
import
minidom
from
avocado.core
import
exit_codes
from
avocado.utils
import
genio
from
avocado.utils
import
process
class
HtmlResultTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
tmpdir
=
tempfile
.
mkdtemp
(
prefix
=
'avocado_'
+
__name__
)
def
check_output_files
(
self
,
debug_log
):
base_dir
=
os
.
path
.
dirname
(
debug_log
)
json_output_path
=
os
.
path
.
join
(
base_dir
,
'results.json'
)
self
.
assertTrue
(
os
.
path
.
isfile
(
json_output_path
))
with
open
(
json_output_path
,
'r'
)
as
fp
:
json
.
load
(
fp
)
xunit_output_path
=
os
.
path
.
join
(
base_dir
,
'results.xml'
)
self
.
assertTrue
(
os
.
path
.
isfile
(
json_output_path
))
try
:
minidom
.
parse
(
xunit_output_path
)
except
Exception
as
details
:
xunit_output_content
=
genio
.
read_file
(
xunit_output_path
)
raise
AssertionError
(
"Unable to parse xunit output: %s
\n\n
%s"
%
(
details
,
xunit_output_content
))
tap_output
=
os
.
path
.
join
(
base_dir
,
"results.tap"
)
self
.
assertTrue
(
os
.
path
.
isfile
(
tap_output
))
tap
=
genio
.
read_file
(
tap_output
)
self
.
assertIn
(
".."
,
tap
)
self
.
assertIn
(
"
\n
# debug.log of "
,
tap
)
def
test_output_incompatible_setup
(
self
):
cmd_line
=
(
'avocado run --job-results-dir %s --sysinfo=off '
'--html - passtest.py'
%
self
.
tmpdir
)
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
)
expected_rc
=
exit_codes
.
AVOCADO_JOB_FAIL
output
=
result
.
stdout
+
result
.
stderr
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
expected_rc
,
result
))
error_excerpt
=
b
"HTML to stdout not supported"
self
.
assertIn
(
error_excerpt
,
output
,
"Missing excerpt error message from output:
\n
%s"
%
output
)
def
test_output_compatible_setup_2
(
self
):
prefix
=
'avocado_'
+
__name__
tmpfile
=
tempfile
.
mktemp
(
prefix
=
prefix
,
dir
=
self
.
tmpdir
)
tmpfile2
=
tempfile
.
mktemp
(
prefix
=
prefix
,
dir
=
self
.
tmpdir
)
tmpdir
=
tempfile
.
mkdtemp
(
prefix
=
prefix
,
dir
=
self
.
tmpdir
)
tmpfile3
=
os
.
path
.
join
(
tmpdir
,
"result.html"
)
cmd_line
=
(
'avocado run --job-results-dir %s --sysinfo=off '
'--xunit %s --json %s --html %s --tap-include-logs '
'passtest.py'
%
(
self
.
tmpdir
,
tmpfile
,
tmpfile2
,
tmpfile3
))
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
)
output
=
result
.
stdout
+
result
.
stderr
expected_rc
=
exit_codes
.
AVOCADO_ALL_OK
tmpdir_contents
=
os
.
listdir
(
tmpdir
)
self
.
assertEqual
(
len
(
tmpdir_contents
),
1
,
"Html plugin generated "
"extra files in the result dir: %s"
%
tmpdir_contents
)
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
expected_rc
,
result
))
self
.
assertNotEqual
(
output
,
""
,
"Output is empty"
)
# Check if we are producing valid outputs
with
open
(
tmpfile2
,
'r'
)
as
fp
:
json_results
=
json
.
load
(
fp
)
debug_log
=
json_results
[
'debuglog'
]
self
.
check_output_files
(
debug_log
)
minidom
.
parse
(
tmpfile
)
def
tearDown
(
self
):
shutil
.
rmtree
(
self
.
tmpdir
)
selftests/functional/test_output.py
浏览文件 @
e2151f76
...
...
@@ -6,8 +6,6 @@ import tempfile
import
unittest
from
xml.dom
import
minidom
import
pkg_resources
from
avocado.core
import
exit_codes
from
avocado.core.output
import
TermSupport
from
avocado.utils
import
genio
...
...
@@ -120,14 +118,6 @@ def image_output_uncapable():
return
True
def
html_uncapable
():
try
:
pkg_resources
.
require
(
'avocado-framework-plugin-result-html'
)
return
False
except
pkg_resources
.
DistributionNotFound
:
return
True
def
perl_tap_parser_uncapable
():
return
os
.
system
(
"perl -e 'use TAP::Parser;'"
)
!=
0
...
...
@@ -319,21 +309,6 @@ class OutputPluginTest(unittest.TestCase):
"Missing error message from output:
\n
%s"
%
result
.
stderr
)
@
unittest
.
skipIf
(
html_uncapable
(),
"Uncapable of Avocado Result HTML plugin"
)
def
test_output_incompatible_setup_2
(
self
):
cmd_line
=
(
'%s run --job-results-dir %s --sysinfo=off '
'--html - passtest.py'
%
(
AVOCADO
,
self
.
tmpdir
))
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
)
expected_rc
=
exit_codes
.
AVOCADO_JOB_FAIL
output
=
result
.
stdout
+
result
.
stderr
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
expected_rc
,
result
))
error_excerpt
=
b
"HTML to stdout not supported"
self
.
assertIn
(
error_excerpt
,
output
,
"Missing excerpt error message from output:
\n
%s"
%
output
)
def
test_output_compatible_setup
(
self
):
tmpfile
=
tempfile
.
mktemp
(
dir
=
self
.
tmpdir
)
cmd_line
=
(
'%s run --job-results-dir %s --sysinfo=off '
...
...
@@ -367,36 +342,6 @@ class OutputPluginTest(unittest.TestCase):
self
.
check_output_files
(
debug_log
)
minidom
.
parseString
(
output
)
@
unittest
.
skipIf
(
html_uncapable
(),
"Uncapable of Avocado Result HTML plugin"
)
def
test_output_compatible_setup_3
(
self
):
prefix
=
'avocado_'
+
__name__
tmpfile
=
tempfile
.
mktemp
(
prefix
=
prefix
,
dir
=
self
.
tmpdir
)
tmpfile2
=
tempfile
.
mktemp
(
prefix
=
prefix
,
dir
=
self
.
tmpdir
)
tmpdir
=
tempfile
.
mkdtemp
(
prefix
=
prefix
,
dir
=
self
.
tmpdir
)
tmpfile3
=
os
.
path
.
join
(
tmpdir
,
"result.html"
)
cmd_line
=
(
'%s run --job-results-dir %s --sysinfo=off '
'--xunit %s --json %s --html %s --tap-include-logs '
'passtest.py'
%
(
AVOCADO
,
self
.
tmpdir
,
tmpfile
,
tmpfile2
,
tmpfile3
))
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
)
output
=
result
.
stdout
+
result
.
stderr
expected_rc
=
exit_codes
.
AVOCADO_ALL_OK
tmpdir_contents
=
os
.
listdir
(
tmpdir
)
self
.
assertEqual
(
len
(
tmpdir_contents
),
1
,
"Html plugin generated "
"extra files in the result dir: %s"
%
tmpdir_contents
)
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
expected_rc
,
result
))
self
.
assertNotEqual
(
output
,
""
,
"Output is empty"
)
# Check if we are producing valid outputs
with
open
(
tmpfile2
,
'r'
)
as
fp
:
json_results
=
json
.
load
(
fp
)
debug_log
=
json_results
[
'debuglog'
]
self
.
check_output_files
(
debug_log
)
minidom
.
parse
(
tmpfile
)
def
test_output_compatible_setup_nooutput
(
self
):
tmpfile
=
tempfile
.
mktemp
(
dir
=
self
.
tmpdir
)
tmpfile2
=
tempfile
.
mktemp
(
dir
=
self
.
tmpdir
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录