Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
58cf6f83
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,发现更多精彩内容 >>
提交
58cf6f83
编写于
2月 23, 2016
作者:
L
Lukáš Doktor
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1042 from clebergnu/logging6_first_round
Refactor logging initialization [subset/first round]
上级
6335f210
98493738
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
71 addition
and
50 deletion
+71
-50
avocado/core/job.py
avocado/core/job.py
+8
-8
avocado/core/loader.py
avocado/core/loader.py
+1
-2
avocado/core/output.py
avocado/core/output.py
+21
-10
avocado/core/remote/runner.py
avocado/core/remote/runner.py
+1
-1
avocado/core/sysinfo.py
avocado/core/sysinfo.py
+1
-1
avocado/plugins/html.py
avocado/plugins/html.py
+1
-0
avocado/plugins/json.py
avocado/plugins/json.py
+1
-1
avocado/plugins/multiplex.py
avocado/plugins/multiplex.py
+0
-1
avocado/plugins/remote.py
avocado/plugins/remote.py
+3
-2
avocado/plugins/vm.py
avocado/plugins/vm.py
+3
-2
avocado/plugins/wrapper.py
avocado/plugins/wrapper.py
+2
-1
selftests/functional/test_multiplex.py
selftests/functional/test_multiplex.py
+20
-13
selftests/functional/test_standalone.py
selftests/functional/test_standalone.py
+5
-4
selftests/unit/test_jsonresult.py
selftests/unit/test_jsonresult.py
+2
-2
selftests/unit/test_xunit.py
selftests/unit/test_xunit.py
+2
-2
未找到文件。
avocado/core/job.py
浏览文件 @
58cf6f83
...
...
@@ -118,8 +118,8 @@ class Job(object):
if
self
.
show_job_log
:
if
not
self
.
silent
:
output
.
add_
console_handler
(
_TEST_LOGGER
)
output
.
add_
console_handler
(
logging
.
getLogger
()
)
output
.
add_
log_handler
(
_TEST_LOGGER
.
name
,
level
=
logging
.
DEBUG
)
output
.
add_
log_handler
(
''
,
level
=
logging
.
DEBUG
)
_TEST_LOGGER
.
setLevel
(
self
.
loglevel
)
_TEST_LOGGER
.
propagate
=
False
...
...
@@ -405,14 +405,14 @@ class Job(object):
that configure a job failure.
"""
self
.
_setup_job_results
()
self
.
view
.
start_
file
_logging
(
self
.
logfile
,
self
.
loglevel
,
self
.
unique_id
,
self
.
replay_sourcejob
)
self
.
view
.
start_
job
_logging
(
self
.
logfile
,
self
.
loglevel
,
self
.
unique_id
,
self
.
replay_sourcejob
)
try
:
test_suite
=
self
.
_make_test_suite
(
self
.
urls
)
except
loader
.
LoaderError
,
details
:
stacktrace
.
log_exc_info
(
sys
.
exc_info
(),
'avocado.app.
tracebacks
'
)
stacktrace
.
log_exc_info
(
sys
.
exc_info
(),
'avocado.app.
debug
'
)
self
.
_remove_job_results
()
raise
exceptions
.
OptionValidationError
(
details
)
if
not
test_suite
:
...
...
@@ -445,7 +445,7 @@ class Job(object):
failures
=
self
.
test_runner
.
run_suite
(
test_suite
,
mux
,
timeout
=
self
.
timeout
,
replay_map
=
replay_map
)
self
.
view
.
stop_
file
_logging
()
self
.
view
.
stop_
job
_logging
()
# If it's all good so far, set job status to 'PASS'
if
self
.
status
==
'RUNNING'
:
self
.
status
=
'PASS'
...
...
avocado/core/loader.py
浏览文件 @
58cf6f83
...
...
@@ -210,8 +210,7 @@ class TestLoaderProxy(object):
"%s"
%
(
plugin
,
details
),
'avocado.app.exceptions'
)
# FIXME: Introduce avocado.traceback logger and use here
stacktrace
.
log_exc_info
(
sys
.
exc_info
(),
'avocado.app.tracebacks'
)
stacktrace
.
log_exc_info
(
sys
.
exc_info
(),
'avocado.app.debug'
)
tests
=
[]
unhandled_urls
=
[]
if
not
urls
:
...
...
avocado/core/output.py
浏览文件 @
58cf6f83
...
...
@@ -111,16 +111,27 @@ def get_paginator():
return
Paginator
()
def
add_console_handler
(
logger
):
def
add_log_handler
(
logger
,
klass
=
logging
.
StreamHandler
,
stream
=
sys
.
stdout
,
level
=
logging
.
INFO
,
fmt
=
'%(name)s: %(message)s'
):
"""
Add a console handler to a logger.
:param logger: `logging.Logger` instance.
Add handler to a logger.
:param logger_name: the name of a :class:`logging.Logger` instance, that
is, the parameter to :func:`logging.getLogger`
:param klass: Handler class (defaults to :class:`logging.StreamHandler`)
:param stream: Logging stream, to be passed as an argument to ``klass``
(defaults to ``sys.stdout``)
:param level: Log level (defaults to `INFO``)
:param fmt: Logging format (defaults to ``%(name)s: %(message)s``)
"""
console_handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
formatter
=
logging
.
Formatter
(
fmt
=
'%(message)s'
)
console_handler
.
setFormatter
(
formatter
)
logger
.
addHandler
(
console_handler
)
handler
=
klass
(
stream
)
handler
.
setLevel
(
level
)
if
isinstance
(
fmt
,
str
):
fmt
=
logging
.
Formatter
(
fmt
=
fmt
)
handler
.
setFormatter
(
fmt
)
logging
.
getLogger
(
logger
).
addHandler
(
handler
)
logging
.
getLogger
(
logger
).
propagate
=
False
return
handler
class
TermSupport
(
object
):
...
...
@@ -547,7 +558,7 @@ class View(object):
"""
self
.
_log_ui_info
(
term_support
.
warn_header_str
(
msg
),
skip_newline
)
def
start_
file
_logging
(
self
,
logfile
,
loglevel
,
unique_id
,
sourcejob
=
None
):
def
start_
job
_logging
(
self
,
logfile
,
loglevel
,
unique_id
,
sourcejob
=
None
):
"""
Start the main file logging.
...
...
@@ -573,7 +584,7 @@ class View(object):
root_logger
.
setLevel
(
loglevel
)
self
.
replay_sourcejob
=
sourcejob
def
stop_
file
_logging
(
self
):
def
stop_
job
_logging
(
self
):
"""
Simple helper for removing a handler from the current logger.
"""
...
...
avocado/core/remote/runner.py
浏览文件 @
58cf6f83
...
...
@@ -211,7 +211,7 @@ class RemoteTestRunner(TestRunner):
logger_list
=
[
fabric_logger
]
if
self
.
job
.
args
.
show_job_log
:
logger_list
.
append
(
app_logger
)
output
.
add_
console_handler
(
paramiko_logger
)
output
.
add_
log_handler
(
paramiko_logger
.
name
)
sys
.
stdout
=
output
.
LoggingFile
(
logger
=
logger_list
)
sys
.
stderr
=
output
.
LoggingFile
(
logger
=
logger_list
)
try
:
...
...
avocado/core/sysinfo.py
浏览文件 @
58cf6f83
...
...
@@ -541,7 +541,7 @@ def collect_sysinfo(args):
:param args: :class:`argparse.Namespace` object with command line params.
"""
output
.
add_
console_handler
(
log
)
output
.
add_
log_handler
(
log
.
name
)
basedir
=
args
.
sysinfodir
if
not
basedir
:
...
...
avocado/plugins/html.py
浏览文件 @
58cf6f83
...
...
@@ -20,6 +20,7 @@ from avocado.core import exit_codes
from
avocado.core
import
output
from
avocado.core.html
import
HTMLTestResult
from
avocado.core.result
import
register_test_result_class
from
.base
import
CLI
...
...
avocado/plugins/json.py
浏览文件 @
58cf6f83
...
...
@@ -16,8 +16,8 @@
JSON output module.
"""
from
avocado.core.result
import
register_test_result_class
from
avocado.core.jsonresult
import
JSONTestResult
from
avocado.core.result
import
register_test_result_class
from
.base
import
CLI
...
...
avocado/plugins/multiplex.py
浏览文件 @
58cf6f83
...
...
@@ -90,7 +90,6 @@ class Multiplex(CLICmd):
elif
not
args
.
tree
and
args
.
inherit
:
err
=
"Option --inherit can be only used with --tree"
if
err
:
view
.
notify
(
event
=
"minor"
,
msg
=
self
.
parser
.
format_help
())
view
.
notify
(
event
=
"error"
,
msg
=
err
)
sys
.
exit
(
exit_codes
.
AVOCADO_FAIL
)
try
:
...
...
avocado/plugins/remote.py
浏览文件 @
58cf6f83
...
...
@@ -14,15 +14,16 @@
"""Run tests on a remote machine."""
import
sys
import
getpass
import
sys
from
avocado.core
import
output
from
avocado.core
import
exit_codes
from
avocado.core
import
output
from
avocado.core
import
remoter
from
avocado.core.remote
import
RemoteTestResult
from
avocado.core.remote
import
RemoteTestRunner
from
avocado.core.result
import
register_test_result_class
from
.base
import
CLI
...
...
avocado/plugins/vm.py
浏览文件 @
58cf6f83
...
...
@@ -14,15 +14,16 @@
"""Run tests on Virtual Machine."""
import
sys
import
getpass
import
sys
from
avocado.core
import
output
from
avocado.core
import
exit_codes
from
avocado.core
import
output
from
avocado.core
import
virt
from
avocado.core.remote
import
VMTestResult
from
avocado.core.remote
import
VMTestRunner
from
avocado.core.result
import
register_test_result_class
from
.base
import
CLI
...
...
avocado/plugins/wrapper.py
浏览文件 @
58cf6f83
...
...
@@ -15,11 +15,12 @@
import
os
import
sys
from
.base
import
CLI
from
avocado.core
import
exit_codes
from
avocado.core
import
output
from
avocado.utils
import
process
from
.base
import
CLI
class
Wrapper
(
CLI
):
...
...
selftests/functional/test_multiplex.py
浏览文件 @
58cf6f83
...
...
@@ -94,20 +94,27 @@ class MultiplexTests(unittest.TestCase):
self
.
run_and_check
(
cmd_line
,
expected_rc
)
def
test_run_mplex_params
(
self
):
cmd_line
=
(
'./scripts/avocado run --job-results-dir %s --sysinfo=off examples/tests/env_variables.sh '
'--multiplex examples/tests/env_variables.sh.data'
'/env_variables.yaml '
'--show-job-log'
%
self
.
tmpdir
)
expected_rc
=
exit_codes
.
AVOCADO_ALL_OK
result
=
self
.
run_and_check
(
cmd_line
,
expected_rc
)
for
msg
in
(
'A'
,
'ASDFASDF'
,
'This is very long
\n
multiline
\n
text.'
):
msg
=
(
'[stdout] Custom variable: '
+
'
\n
[stdout] '
.
join
(
msg
.
splitlines
()))
self
.
assertIn
(
msg
,
result
.
stdout
,
"Multiplexed variable should "
"produce:"
for
variant_msg
in
((
'/run/short'
,
'A'
),
(
'/run/medium'
,
'ASDFASDF'
),
(
'/run/long'
,
'This is very long
\n
multiline
\n
text.'
)):
variant
,
msg
=
variant_msg
cmd_line
=
(
'./scripts/avocado run --job-results-dir %s --sysinfo=off examples/tests/env_variables.sh '
'--multiplex examples/tests/env_variables.sh.data/env_variables.yaml '
'--filter-only %s --show-job-log'
%
(
self
.
tmpdir
,
variant
))
expected_rc
=
exit_codes
.
AVOCADO_ALL_OK
result
=
self
.
run_and_check
(
cmd_line
,
expected_rc
)
msg_lines
=
msg
.
splitlines
()
msg_header
=
'[stdout] Custom variable: %s'
%
msg_lines
[
0
]
self
.
assertIn
(
msg_header
,
result
.
stdout
,
"Multiplexed variable should produce:"
"
\n
%s
\n
which is not present in the output:
\n
%s"
%
(
"
\n
"
.
join
(
msg
.
splitlines
()),
"
\n
"
.
join
(
result
.
stdout
.
splitlines
())))
%
(
msg_header
,
"
\n
"
.
join
(
result
.
stdout
.
splitlines
())))
for
msg_remain
in
msg_lines
[
1
:]:
self
.
assertIn
(
'[stdout] %s'
%
msg_remain
,
result
.
stdout
,
"Multiplexed variable should produce:"
"
\n
%s
\n
which is not present in the output:
\n
%s"
%
(
msg_remain
,
"
\n
"
.
join
(
result
.
stdout
.
splitlines
())))
def
tearDown
(
self
):
shutil
.
rmtree
(
self
.
tmpdir
)
...
...
selftests/functional/test_standalone.py
浏览文件 @
58cf6f83
...
...
@@ -51,10 +51,11 @@ class StandaloneTests(unittest.TestCase):
expected_rc
=
exit_codes
.
AVOCADO_TESTS_FAIL
result
=
self
.
run_and_check
(
cmd_line
,
expected_rc
,
'errortest_nasty'
)
exc
=
"NastyException: Nasty-string-like-exception"
count
=
result
.
stdout
.
count
(
"
\n
%s"
%
exc
)
self
.
assertEqual
(
count
,
2
,
"Exception
\\
n%s should be present twice in"
"the log (once from the log, second time when parsing"
"exception details."
%
(
exc
))
count
=
result
.
stdout
.
count
(
"%s"
%
exc
)
self
.
assertEqual
(
count
,
3
,
"Exception
\\
n%s should be present three "
"times in the log (first from the traceback, then "
"from the test log when raising the exception, and "
"finally from the test results."
%
(
exc
))
def
test_errortest_nasty2
(
self
):
cmd_line
=
'./examples/tests/errortest_nasty2.py -r'
...
...
selftests/unit/test_jsonresult.py
浏览文件 @
58cf6f83
...
...
@@ -12,10 +12,10 @@ from avocado.core import job
class
_Stream
(
object
):
def
start_
file
_logging
(
self
,
param1
,
param2
):
def
start_
job
_logging
(
self
,
param1
,
param2
):
pass
def
stop_
file
_logging
(
self
):
def
stop_
job
_logging
(
self
):
pass
def
set_tests_info
(
self
,
info
):
...
...
selftests/unit/test_xunit.py
浏览文件 @
58cf6f83
...
...
@@ -16,10 +16,10 @@ class ParseXMLError(Exception):
class
_Stream
(
object
):
def
start_
file
_logging
(
self
,
param1
,
param2
):
def
start_
job
_logging
(
self
,
param1
,
param2
):
pass
def
stop_
file
_logging
(
self
):
def
stop_
job
_logging
(
self
):
pass
def
set_tests_info
(
self
,
info
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录