Commit f89c3b55 authored by Jérome Perrin's avatar Jérome Perrin

PyTest.summaryf: better detection of summary line

If program output after pytest's summary line, our summary function
would be confused and detect 0 test run.
Make this matching more robust by expecting the actual status of tests
reported by pytest: (x)passed, (x)failed, skipped errors or "no test run"

From Kirill's suggestion on nexedi/nxdtest!17 (comment 162070)

/reviewed-by @kirr
/reviewed-on nexedi/nxdtest!17
parent d9f8a345
......@@ -499,7 +499,7 @@ class PyTest:
# ...
textv = out.splitlines()
for l in reversed(textv):
if re.match(b'^====* .* ====*$', l):
if re.match(rb'^====* .*(failed|passed|skipped|error|no tests).* ====*$', l):
pytail = l
break
else:
......
......@@ -131,6 +131,46 @@ golang/time_test.py:106: AssertionError
b(''),
'fail\ttestname\t1.000s\t# 112t 0e 1f 13s')
case1('notest', b("""\
============================= test session starts ==============================
platform linux -- Python 3.7.7, pytest-4.6.11, py-1.9.0, pluggy-0.13.1
rootdir: /srv/slapgrid/slappart15/srv/runner/software/104d3d67a7dca200da22b97280c85eb6/parts/nxdtest, inifile: pytest.ini
plugins: timeout-1.4.2, mock-2.0.0
collected 0 items
========================= no tests ran in 0.01 seconds =========================
"""),
b(''),
'ok\ttestname\t1.000s\t# 0t 0e 0f 0s')
case1('error', b("""\
============================= test session starts ==============================
platform linux -- Python 3.7.7, pytest-4.6.11, py-1.9.0, pluggy-0.13.1
rootdir: /srv/slapgrid/slappart15/srv/runner/software/104d3d67a7dca200da22b97280c85eb6/parts/nxdtest, inifile: pytest.ini
plugins: timeout-1.4.2, mock-2.0.0
collected 0 items / 2 errors
==================================== ERRORS ====================================
_________________________ ERROR collecting tmp/test.py _________________________
ImportError while importing test module 'tmp/test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
test.py:4: in <module>
import error
E ModuleNotFoundError: No module named 'error'
________________________ ERROR collecting tmp/test2.py _________________________
ImportError while importing test module 'tmp/test2.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
test2.py:4: in <module>
import error
E ModuleNotFoundError: No module named 'error'
!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!
=========================== 2 error in 0.11 seconds ============================
"""),
b(''),
'error\ttestname\t1.000s\t# 2t 2e 0f 0s')
case1('ok+tailtext', b("""\
date: Sun, 08 Nov 2020 12:26:24 MSK
xnode: kirr@deco.navytux.spb.ru
......@@ -146,6 +186,7 @@ wcfs: 2020/11/08 12:26:38 /tmp/testdb_fs.Z9IvT0/1.fs: watcher: stat /tmp/testdb_
# unmount/stop wcfs pid39653 @ /tmp/wcfs/40cc7154ed758d6a867205e79e320c1d3b56458d
wcfs: 2020/11/08 12:26:38 /tmp/testdb_fs.B3rbby/1.fs: watcher: stat /tmp/testdb_fs.B3rbby/1.fs: use of closed file
# unmount/stop wcfs pid39595 @ /tmp/wcfs/d0b5d036a2cce47fe73003cf2d9f0b22c7043817
==== aaa bbb ====
"""),
b(''),
'ok\ttestname\t1.000s\t# 55t 0e 0f 0s')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment