Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
02db6577
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,发现更多精彩内容 >>
提交
02db6577
编写于
9月 17, 2014
作者:
C
Cleber Rosa
提交者:
clebergnu
9月 17, 2014
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #213 from clebergnu/ruda_multiplex_updates
Ruda's multiplex updates
上级
b8282a0d
dc64e112
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
100 addition
and
17 deletion
+100
-17
avocado/core/tree.py
avocado/core/tree.py
+3
-2
avocado/job.py
avocado/job.py
+4
-4
avocado/multiplexer.py
avocado/multiplexer.py
+34
-11
selftests/all/unit/avocado/multiplexer_unittest.py
selftests/all/unit/avocado/multiplexer_unittest.py
+59
-0
未找到文件。
avocado/core/tree.py
浏览文件 @
02db6577
...
...
@@ -51,10 +51,11 @@ class TreeNode(object):
self
.
children
=
children
def
__repr__
(
self
):
return
'TreeNode(name=%r
, value=%r, parent=%r, children=%r)'
%
(
self
.
name
,
self
.
value
,
self
.
parent
,
self
.
children
)
return
'TreeNode(name=%r
)'
%
self
.
name
def
__str__
(
self
):
return
'%s=%r'
%
(
self
.
name
,
self
.
environment
)
variables
=
[
'%s=%s'
%
(
k
,
v
)
for
k
,
v
in
self
.
environment
.
items
()]
return
'%s: %s'
%
(
self
.
path
,
', '
.
join
(
variables
))
def
__len__
(
self
):
return
len
(
self
.
get_leaves
())
...
...
avocado/job.py
浏览文件 @
02db6577
...
...
@@ -415,6 +415,9 @@ class Job(object):
if
urls
is
not
None
:
for
url
in
urls
:
params_list
.
append
({
'id'
:
url
})
else
:
e_msg
=
"Empty test ID. A test path or alias must be provided"
raise
exceptions
.
OptionValidationError
(
e_msg
)
if
multiplex_file
is
None
:
if
self
.
args
and
self
.
args
.
multiplex_file
is
not
None
:
...
...
@@ -438,12 +441,9 @@ class Job(object):
params_list
.
append
(
var
.
environment
)
else
:
params_list
.
append
({
'id'
:
url
})
else
:
e_msg
=
"Empty test ID. A test path or alias must be provided"
raise
exceptions
.
OptionValidationError
(
e_msg
)
if
not
params_list
:
e_msg
=
"
Empty test ID. A test path or alias must be provided
"
e_msg
=
"
Test(s) with empty parameter list or the number of variants is zero
"
raise
exceptions
.
OptionValidationError
(
e_msg
)
if
self
.
args
is
not
None
:
...
...
avocado/multiplexer.py
浏览文件 @
02db6577
...
...
@@ -24,16 +24,30 @@ import collections
from
avocado.core
import
tree
def
path_parent
(
element
):
e
=
element
.
rpartition
(
'/'
)[
0
]
if
e
==
''
:
return
'/'
return
e
def
any_sibling
(
*
args
):
result
=
set
(
arg
.
parent
for
arg
in
args
)
return
len
(
args
)
!=
len
(
result
)
def
path_parent
(
path
):
"""
From a given path, return its parent path.
:param path: the node path as string.
:return: the parent path as string.
"""
parent
=
path
.
rpartition
(
'/'
)[
0
]
if
parent
==
''
:
return
'/root'
return
parent
def
any_sibling
(
*
nodes
):
"""
Check if there is any sibling.
:param nodes: the nodes to check.
:return: `True` if there is any sibling or `False`.
"""
if
len
(
nodes
)
<
2
:
return
False
parents
=
set
(
node
.
parent
for
node
in
nodes
)
return
len
(
nodes
)
!=
len
(
parents
)
# only allow items which match the filter
# siblings and their children will be removed
...
...
@@ -41,6 +55,11 @@ def any_sibling(*args):
def
filter_only
(
keys
,
items
):
if
isinstance
(
keys
,
str
):
keys
=
[
keys
]
if
isinstance
(
items
,
str
):
items
=
[
items
]
# the default rule is to accept
ret
=
True
...
...
@@ -67,6 +86,11 @@ def filter_only(keys, items):
def
filter_out
(
keys
,
items
):
if
isinstance
(
keys
,
str
):
keys
=
[
keys
]
if
isinstance
(
items
,
str
):
items
=
[
items
]
for
key
in
keys
:
# ignore empty filters
if
key
==
''
:
...
...
@@ -107,7 +131,6 @@ def multiplex(*args, **kwargs):
# second level of filtering above should use the filter strings
# extracted from the node being worked on
# (not implemented here, so using [] as placeholders)
result
=
[
x
+
[
y
]
for
x
in
result
for
y
in
pool
if
any_sibling
(
*
(
x
+
[
y
]))
is
False
and
filter_only
(
y
.
environment
.
get
(
'filter-only'
,
[]),
x
+
[
y
])
and
...
...
selftests/all/unit/avocado/multiplexer_unittest.py
浏览文件 @
02db6577
...
...
@@ -25,6 +25,65 @@ f_only = []
f_out
=
[]
class
TestPathParent
(
unittest
.
TestCase
):
def
test_empty_string
(
self
):
self
.
assertEqual
(
path_parent
(
''
),
'/root'
)
def
test_on_root
(
self
):
self
.
assertEqual
(
path_parent
(
'/root'
),
'/root'
)
def
test_direct_parent
(
self
):
self
.
assertEqual
(
path_parent
(
'/root/os/linux'
),
'/root/os'
)
def
test_false_direct_parent
(
self
):
self
.
assertNotEqual
(
path_parent
(
'/root/os/linux'
),
'/root'
)
class
TestAnySibling
(
unittest
.
TestCase
):
def
setUp
(
self
):
"""
Setup the following tree node structure:
os:
linux:
mint:
fedora:
win:
winxp:
win7:
win8:
"""
t
=
TreeNode
(
'/root'
)
os
=
t
.
add_child
(
TreeNode
(
'os'
))
linux
=
os
.
add_child
(
TreeNode
(
'linux'
))
self
.
mint
=
linux
.
add_child
(
TreeNode
(
'mint'
))
self
.
fedora
=
linux
.
add_child
(
TreeNode
(
'mint'
))
win
=
os
.
add_child
(
TreeNode
(
'win'
))
self
.
winxp
=
win
.
add_child
(
TreeNode
(
'winxp'
))
self
.
win7
=
win
.
add_child
(
TreeNode
(
'win7'
))
self
.
win8
=
win
.
add_child
(
TreeNode
(
'win8'
))
def
test_empty
(
self
):
self
.
assertFalse
(
any_sibling
())
def
test_one_node
(
self
):
t
=
TreeNode
()
n
=
t
.
add_child
(
TreeNode
(
'alone'
))
self
.
assertFalse
(
any_sibling
(
n
))
def
test_same_parent
(
self
):
self
.
assertTrue
(
any_sibling
(
self
.
mint
,
self
.
fedora
))
self
.
assertTrue
(
any_sibling
(
self
.
winxp
,
self
.
win7
,
self
.
win8
))
def
test_one_linux_one_windows
(
self
):
self
.
assertFalse
(
any_sibling
(
self
.
mint
,
self
.
winxp
))
def
test_two_linux_one_windows
(
self
):
self
.
assertTrue
(
any_sibling
(
self
.
mint
,
self
.
fedora
,
self
.
winxp
))
class
TestMultiplex
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录