Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
f35378a8
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,发现更多精彩内容 >>
未验证
提交
f35378a8
编写于
9月 22, 2018
作者:
C
Caio Carrara
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'clebergnu/revert_yaml_to_mux_py3'
Signed-off-by:
N
Caio Carrara
<
ccarrara@redhat.com
>
上级
5be90eaa
8cc9be2a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
38 addition
and
52 deletion
+38
-52
optional_plugins/varianter_yaml_to_mux/avocado_varianter_yaml_to_mux/__init__.py
...ter_yaml_to_mux/avocado_varianter_yaml_to_mux/__init__.py
+8
-12
optional_plugins/varianter_yaml_to_mux/tests/.data/mux-selftest-advanced.yaml
...ianter_yaml_to_mux/tests/.data/mux-selftest-advanced.yaml
+9
-9
optional_plugins/varianter_yaml_to_mux/tests/.data/mux-selftest-distro.yaml
...arianter_yaml_to_mux/tests/.data/mux-selftest-distro.yaml
+0
-0
optional_plugins/varianter_yaml_to_mux/tests/.data/mux-selftest.yaml
...ugins/varianter_yaml_to_mux/tests/.data/mux-selftest.yaml
+1
-2
optional_plugins/varianter_yaml_to_mux/tests/test_multiplex.py
...nal_plugins/varianter_yaml_to_mux/tests/test_multiplex.py
+6
-2
optional_plugins/varianter_yaml_to_mux/tests/test_mux.py
optional_plugins/varianter_yaml_to_mux/tests/test_mux.py
+14
-27
未找到文件。
optional_plugins/varianter_yaml_to_mux/avocado_varianter_yaml_to_mux/__init__.py
浏览文件 @
f35378a8
...
...
@@ -31,7 +31,6 @@ from six import iteritems
from
avocado.core
import
exit_codes
from
avocado.core.output
import
LOG_UI
from
avocado.core.plugin_interfaces
import
CLI
,
Varianter
from
avocado.utils
import
astring
from
.
import
mux
...
...
@@ -137,9 +136,8 @@ def _create_from_yaml(path, cls_node=mux.MuxTreeNode):
else
:
handle_control_tag
(
node
,
value
)
elif
isinstance
(
value
[
1
],
collections
.
OrderedDict
):
child
=
tree_node_from_values
(
astring
.
to_text
(
value
[
0
]),
value
[
1
])
node
.
add_child
(
child
)
node
.
add_child
(
tree_node_from_values
(
str
(
value
[
0
]),
value
[
1
]))
else
:
node
.
value
[
value
[
0
]]
=
value
[
1
]
return
using
...
...
@@ -176,7 +174,7 @@ def _create_from_yaml(path, cls_node=mux.MuxTreeNode):
return
node
# Initialize the node
node
=
cls_node
(
astring
.
to_text
(
name
))
node
=
cls_node
(
str
(
name
))
if
not
values
:
return
node
using
=
''
...
...
@@ -220,7 +218,7 @@ def _create_from_yaml(path, cls_node=mux.MuxTreeNode):
if
isinstance
(
values
,
ListOfNodeObjects
):
# New node from list
objects
.
append
(
tree_node_from_values
(
name
,
values
))
elif
values
is
None
:
# Empty node
objects
.
append
(
cls_node
(
astring
.
to_text
(
name
)))
objects
.
append
(
cls_node
(
str
(
name
)))
else
:
# Values
objects
.
append
((
name
,
values
))
return
objects
...
...
@@ -321,11 +319,10 @@ def create_from_yaml(paths, debug=False):
merge
(
data
,
path
)
# Yaml can raise IndexError on some files
except
(
yaml
.
YAMLError
,
IndexError
)
as
details
:
if
(
u
'mapping values are not allowed in this context'
in
astring
.
to_text
(
details
)):
details
=
(
u
"%s
\n
Make sure !tags and colons are separated by a "
u
"space (eg. !include :)"
%
details
)
msg
=
u
"Invalid multiplex file '%s': %s"
%
(
path
,
details
)
if
'mapping values are not allowed in this context'
in
str
(
details
):
details
=
(
"%s
\n
Make sure !tags and colons are separated by a "
"space (eg. !include :)"
%
details
)
msg
=
"Invalid multiplex file '%s': %s"
%
(
path
,
details
)
raise
IOError
(
2
,
msg
,
path
)
return
data
...
...
@@ -380,7 +377,6 @@ class YamlToMux(mux.MuxPlugin, Varianter):
def
initialize
(
self
,
args
):
debug
=
getattr
(
args
,
"varianter_debug"
,
False
)
if
debug
:
data
=
mux
.
MuxTreeNodeDebug
()
else
:
...
...
optional_plugins/varianter_yaml_to_mux/tests/.data/mux-selftest-advanced.yaml
浏览文件 @
f35378a8
# Put everything into /
š
virt
!using
:
š
virt
# Put everything into /virt
!using
:
virt
# Following line makes it look exactly as mux-selftest.yaml
!include
:
mux-selftest.yaml
distro
:
!mux
# This line extends the distro branch using include
!include
:
mux-
š
elftest-distro.yaml
# remove node called "
š
mint"
!remove_node
:
š
mi.*nt
# This is a new /distro/
š
mint appended as latest child
š
mint
:
!include
:
mux-
s
elftest-distro.yaml
# remove node called "mint"
!remove_node
:
mi.*nt
# This is a new /distro/mint appended as latest child
mint
:
new_mint
:
True
fedora
:
!remove_value
:
init.*
...
...
@@ -27,7 +27,7 @@ new_node:
# removed during parse time, absolute location is not supported and
# not even planned)
!using
:
/absolutely/fresh/
new_value
:
"
š
omething"
new_value
:
"
s
omething"
# Check that mapping keys are not converted to values, while values are
# while value between quotes stays as string.
on
:
...
...
@@ -39,7 +39,7 @@ on:
# should be similar.
dict
:
explicit
:
!!python/dict
foo
š
:
š
bar
foo
:
bar
bar
:
baz
in_list
:
-
foo
:
bar
...
...
optional_plugins/varianter_yaml_to_mux/tests/.data/mux-
š
elftest-distro.yaml
→
optional_plugins/varianter_yaml_to_mux/tests/.data/mux-
s
elftest-distro.yaml
浏览文件 @
f35378a8
文件已移动
optional_plugins/varianter_yaml_to_mux/tests/.data/mux-selftest.yaml
浏览文件 @
f35378a8
...
...
@@ -55,6 +55,5 @@ env: !mux
prod
:
opt_CFLAGS
:
'
-O2'
distro
:
!mux
# Use utf-8 character
šmint
:
mint
:
init
:
'
systemv'
optional_plugins/varianter_yaml_to_mux/tests/test_multiplex.py
浏览文件 @
f35378a8
...
...
@@ -7,11 +7,11 @@ import sys
from
avocado.core
import
exit_codes
from
avocado.utils
import
process
basedir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
'..'
,
'..'
,
'..'
)
basedir
=
os
.
path
.
abspath
(
basedir
)
AVOCADO
=
os
.
environ
.
get
(
"UNITTEST_AVOCADO_CMD"
,
"%s ./scripts/avocado"
%
sys
.
executable
)
AVOCADO
=
os
.
environ
.
get
(
"UNITTEST_AVOCADO_CMD"
,
"./scripts/avocado"
)
DEBUG_OUT
=
b
"""
Variant mint-debug-amd-virtio-a9d2: amd@optional_plugins/varianter_yaml_to_mux/tests/.data/mux-environment.yaml, virtio@optional_plugins/varianter_yaml_to_mux/tests/.data/mux-environment.yaml, mint@optional_plugins/varianter_yaml_to_mux/tests/.data/mux-environment.yaml, debug@optional_plugins/varianter_yaml_to_mux/tests/.data/mux-environment.yaml
...
...
@@ -55,6 +55,8 @@ class MultiplexTests(unittest.TestCase):
result
=
self
.
run_and_check
(
cmd_line
,
expected_rc
)
self
.
assertIn
(
'No such file or directory'
,
result
.
stderr_text
)
@
unittest
.
skipIf
(
sys
.
version_info
[
0
]
==
3
,
"Test currently broken on Python 3"
)
def
test_mplex_debug
(
self
):
cmd_line
=
(
'%s variants -c -d -m '
'/:optional_plugins/varianter_yaml_to_mux/tests/.data/mux-selftest.yaml '
...
...
@@ -142,6 +144,8 @@ class MultiplexTests(unittest.TestCase):
"passtest.py"
%
(
AVOCADO
,
self
.
tmpdir
))
self
.
run_and_check
(
cmd_line
,
exit_codes
.
AVOCADO_ALL_OK
,
(
1
,
0
))
@
unittest
.
skipIf
(
sys
.
version_info
[
0
]
==
3
,
"Test currently broken on Python 3"
)
def
test_run_mplex_params
(
self
):
for
variant_msg
in
((
'/run/short'
,
'A'
),
(
'/run/medium'
,
'ASDFASDF'
),
...
...
optional_plugins/varianter_yaml_to_mux/tests/test_mux.py
浏览文件 @
f35378a8
...
...
@@ -5,14 +5,11 @@ import pickle
import
sys
import
unittest
from
six
import
PY2
import
yaml
import
avocado_varianter_yaml_to_mux
as
yaml_to_mux
from
avocado_varianter_yaml_to_mux
import
mux
from
avocado.core
import
tree
,
parameters
from
avocado.utils
import
astring
BASEDIR
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
'..'
)
BASEDIR
=
os
.
path
.
abspath
(
BASEDIR
)
...
...
@@ -81,15 +78,10 @@ class TestMuxTree(unittest.TestCase):
def
test_basic_functions
(
self
):
# repr
if
PY2
:
self
.
assertEqual
(
"MuxTreeNode(name=u'hw')"
,
repr
(
self
.
tree
.
children
[
0
]))
else
:
self
.
assertEqual
(
"MuxTreeNode(name='hw')"
,
repr
(
self
.
tree
.
children
[
0
]))
self
.
assertEqual
(
"MuxTreeNode(name='hw')"
,
repr
(
self
.
tree
.
children
[
0
]))
# str
self
.
assertEqual
(
u
"/distro/
\u0161
mint: init=systemv"
,
astring
.
to_text
(
self
.
tree
.
children
[
1
].
children
[
1
]))
self
.
assertEqual
(
"/distro/
mint: init=systemv"
,
str
(
self
.
tree
.
children
[
1
].
children
[
1
]))
# len
self
.
assertEqual
(
8
,
len
(
self
.
tree
))
# number of leaves
# __iter__
...
...
@@ -131,28 +123,23 @@ class TestMuxTree(unittest.TestCase):
vals
=
{
'opt_CFLAGS'
:
'-Os'
}
self
.
assertEqual
(
vals
,
self
.
tree
.
children
[
2
].
environment
)
# leaves order
leaves
=
[
'intel'
,
'amd'
,
'arm'
,
'scsi'
,
'virtio'
,
'fedora'
,
u
'
\u0161
mint'
,
'prod'
]
leaves
=
[
'intel'
,
'amd'
,
'arm'
,
'scsi'
,
'virtio'
,
'fedora'
,
'mint'
,
'prod'
]
self
.
assertEqual
(
leaves
,
self
.
tree
.
get_leaves
())
tree_view
=
tree
.
tree_view
(
self
.
tree
,
0
,
False
)
# ascii treeview contains only ascii chars
tree_view
.
decode
(
'ascii'
)
# ascii treeview contain all leaves
# ascii contain all leaves and doesn't raise any exceptions
tree_view
=
tree
.
tree_view
(
self
.
tree
,
0
,
False
).
decode
(
'ascii'
)
for
leaf
in
leaves
:
# In ascii mode we replace non-ascii character using
# xmlcharrefreplace, make sure this is performed
leaf
=
leaf
.
encode
(
'ascii'
,
errors
=
'xmlcharrefreplace'
)
self
.
assertIn
(
leaf
,
tree_view
,
"Leaf %s not in ascii:
\n
%s"
%
(
leaf
,
tree_view
))
def
test_filters
(
self
):
tree2
=
copy
.
deepcopy
(
self
.
tree
)
exp
=
[
'intel'
,
'amd'
,
'arm'
,
'fedora'
,
u
'
\u0161
mint'
,
'prod'
]
exp
=
[
'intel'
,
'amd'
,
'arm'
,
'fedora'
,
'
mint'
,
'prod'
]
act
=
mux
.
apply_filters
(
tree2
,
filter_only
=
[
'/hw/cpu'
,
''
]).
get_leaves
()
self
.
assertEqual
(
exp
,
act
)
tree2
=
copy
.
deepcopy
(
self
.
tree
)
exp
=
[
'scsi'
,
'virtio'
,
'fedora'
,
u
'
\u0161
mint'
,
'prod'
]
exp
=
[
'scsi'
,
'virtio'
,
'fedora'
,
'
mint'
,
'prod'
]
act
=
mux
.
apply_filters
(
tree2
,
filter_out
=
[
'/hw/cpu'
,
''
]).
get_leaves
()
self
.
assertEqual
(
exp
,
act
)
...
...
@@ -167,7 +154,7 @@ class TestMuxTree(unittest.TestCase):
tree3
.
children
[
0
].
add_child
(
mux
.
MuxTreeNode
(
'cpu'
,
{
'test_value'
:
[
'z'
]}))
tree2
.
merge
(
tree3
)
exp
=
[
'intel'
,
'amd'
,
'arm'
,
'scsi'
,
'virtio'
,
'default'
,
'virtio'
,
'fedora'
,
u
'
\u0161
mint'
,
'prod'
]
'fedora'
,
'
mint'
,
'prod'
]
self
.
assertEqual
(
exp
,
tree2
.
get_leaves
())
self
.
assertEqual
({
'corruptlist'
:
[
'upper_node_list'
],
'another_value'
:
'bbb'
},
...
...
@@ -184,24 +171,24 @@ class TestMuxTree(unittest.TestCase):
tree2_yaml_url
=
'/:%s'
%
tree2_yaml_path
tree2
=
yaml_to_mux
.
create_from_yaml
([
tree2_yaml_url
])
exp
=
[
'intel'
,
'amd'
,
'arm'
,
'scsi'
,
'virtio'
,
'fedora'
,
'6'
,
'7'
,
'gentoo'
,
u
'
\u0161
mint'
,
'prod'
,
'new_node'
,
'on'
,
'dict'
]
'7'
,
'gentoo'
,
'
mint'
,
'prod'
,
'new_node'
,
'on'
,
'dict'
]
act
=
tree2
.
get_leaves
()
oldroot
=
tree2
.
children
[
0
]
self
.
assertEqual
(
exp
,
act
)
self
.
assertEqual
(
tree2
.
children
[
0
].
children
[
0
].
path
,
u
"/
\u0161
virt/hw"
)
self
.
assertEqual
(
tree2
.
children
[
0
].
children
[
0
].
path
,
"/
virt/hw"
)
self
.
assertEqual
({
'enterprise'
:
True
},
oldroot
.
children
[
1
].
children
[
1
].
value
)
self
.
assertEqual
({
'new_init'
:
'systemd'
},
oldroot
.
children
[
1
].
children
[
0
].
value
)
self
.
assertEqual
({
'is_cool'
:
True
},
oldroot
.
children
[
1
].
children
[
2
].
value
)
self
.
assertEqual
({
'new_value'
:
u
'
\u0161
omething'
},
self
.
assertEqual
({
'new_value'
:
's
omething'
},
oldroot
.
children
[
3
].
children
[
0
].
children
[
0
].
value
)
# Convert values, but not keys
self
.
assertEqual
({
'on'
:
True
,
"true"
:
"true"
},
oldroot
.
children
[
4
].
value
)
# Dicts as values
self
.
assertEqual
({
"explicit"
:
{
u
"foo
\u0161
"
:
u
"
\u0161
bar"
,
"bar"
:
"baz"
},
self
.
assertEqual
({
"explicit"
:
{
"foo"
:
"
bar"
,
"bar"
:
"baz"
},
"in_list"
:
[{
"foo"
:
"bar"
,
"bar"
:
"baz"
}]},
oldroot
.
children
[
5
].
value
)
# multiplex root (always True)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录