test: twister: test_runner remove line number check in log
1. remove the line number check in test vector 2. log_info is not a static method anymore, change test Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
This commit is contained in:
parent
4df07224f8
commit
cf053d07e3
|
@ -785,6 +785,7 @@ TESTDATA_4 = [
|
||||||
)
|
)
|
||||||
def test_projectbuilder_log_info(
|
def test_projectbuilder_log_info(
|
||||||
caplog,
|
caplog,
|
||||||
|
mocked_jobserver,
|
||||||
inline_logs,
|
inline_logs,
|
||||||
read_exception,
|
read_exception,
|
||||||
expected_logs
|
expected_logs
|
||||||
|
@ -802,10 +803,14 @@ def test_projectbuilder_log_info(
|
||||||
|
|
||||||
filename = 'dummy_file.log'
|
filename = 'dummy_file.log'
|
||||||
|
|
||||||
|
env_mock = mock.Mock()
|
||||||
|
instance_mock = mock.Mock()
|
||||||
|
|
||||||
|
pb = ProjectBuilder(instance_mock, env_mock, mocked_jobserver)
|
||||||
with mock.patch('builtins.open', mock_open), \
|
with mock.patch('builtins.open', mock_open), \
|
||||||
mock.patch('os.path.realpath', mock_realpath), \
|
mock.patch('os.path.realpath', mock_realpath), \
|
||||||
mock.patch('os.path.abspath', mock_abspath):
|
mock.patch('os.path.abspath', mock_abspath):
|
||||||
ProjectBuilder.log_info(filename, inline_logs)
|
pb.log_info(filename, inline_logs)
|
||||||
|
|
||||||
assert all([log in caplog.text for log in expected_logs])
|
assert all([log in caplog.text for log in expected_logs])
|
||||||
|
|
||||||
|
@ -1876,14 +1881,14 @@ def test_projectbuilder_sanitize_zephyr_base_from_files(
|
||||||
TESTDATA_13 = [
|
TESTDATA_13 = [
|
||||||
(
|
(
|
||||||
'error', True, True, False,
|
'error', True, True, False,
|
||||||
['INFO twister:runner.py:950 20/25 dummy platform' \
|
['INFO 20/25 dummy platform' \
|
||||||
' dummy.testsuite.name' \
|
' dummy.testsuite.name' \
|
||||||
' ERROR dummy reason (cmake)'],
|
' ERROR dummy reason (cmake)'],
|
||||||
None
|
None
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'failed', False, False, False,
|
'failed', False, False, False,
|
||||||
['ERROR twister:runner.py:904 dummy platform' \
|
['ERROR dummy platform' \
|
||||||
' dummy.testsuite.name' \
|
' dummy.testsuite.name' \
|
||||||
' FAILED : dummy reason'],
|
' FAILED : dummy reason'],
|
||||||
'INFO - Total complete: 20/ 25 80% skipped: 3,' \
|
'INFO - Total complete: 20/ 25 80% skipped: 3,' \
|
||||||
|
@ -1891,7 +1896,7 @@ TESTDATA_13 = [
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'skipped', True, False, False,
|
'skipped', True, False, False,
|
||||||
['INFO twister:runner.py:950 20/25 dummy platform' \
|
['INFO 20/25 dummy platform' \
|
||||||
' dummy.testsuite.name' \
|
' dummy.testsuite.name' \
|
||||||
' SKIPPED (dummy reason)'],
|
' SKIPPED (dummy reason)'],
|
||||||
None
|
None
|
||||||
|
@ -1904,7 +1909,7 @@ TESTDATA_13 = [
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'passed', True, False, True,
|
'passed', True, False, True,
|
||||||
['INFO twister:runner.py:950 20/25 dummy platform' \
|
['INFO 20/25 dummy platform' \
|
||||||
' dummy.testsuite.name' \
|
' dummy.testsuite.name' \
|
||||||
' PASSED' \
|
' PASSED' \
|
||||||
' (dummy handler type: dummy dut, 60.000s)'],
|
' (dummy handler type: dummy dut, 60.000s)'],
|
||||||
|
@ -1912,7 +1917,7 @@ TESTDATA_13 = [
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'passed', True, False, False,
|
'passed', True, False, False,
|
||||||
['INFO twister:runner.py:950 20/25 dummy platform' \
|
['INFO 20/25 dummy platform' \
|
||||||
' dummy.testsuite.name' \
|
' dummy.testsuite.name' \
|
||||||
' PASSED (build)'],
|
' PASSED (build)'],
|
||||||
None
|
None
|
||||||
|
@ -1925,7 +1930,7 @@ TESTDATA_13 = [
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'timeout', True, False, True,
|
'timeout', True, False, True,
|
||||||
['INFO twister:runner.py:950 20/25 dummy platform' \
|
['INFO 20/25 dummy platform' \
|
||||||
' dummy.testsuite.name' \
|
' dummy.testsuite.name' \
|
||||||
' UNKNOWN' \
|
' UNKNOWN' \
|
||||||
' (dummy handler type: dummy dut, 60.000s/seed: 123)'],
|
' (dummy handler type: dummy dut, 60.000s/seed: 123)'],
|
||||||
|
@ -1988,11 +1993,13 @@ def test_projectbuilder_report_out(
|
||||||
|
|
||||||
assert results_mock.cases == 25
|
assert results_mock.cases == 25
|
||||||
|
|
||||||
assert all([log in re.sub(
|
trim_actual_log = re.sub(
|
||||||
r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])',
|
r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])',
|
||||||
'',
|
'',
|
||||||
caplog.text
|
caplog.text
|
||||||
) for log in expected_logs])
|
)
|
||||||
|
trim_actual_log = re.sub(r'twister:runner.py:\d+', '', trim_actual_log)
|
||||||
|
assert all([log in trim_actual_log for log in expected_logs])
|
||||||
|
|
||||||
if expected_out:
|
if expected_out:
|
||||||
out, err = capfd.readouterr()
|
out, err = capfd.readouterr()
|
||||||
|
|
Loading…
Reference in a new issue