Commit d829e9ca authored by Kirill Smelkov's avatar Kirill Smelkov

PyTest: summary: Skip trail text after test summary

For example wendelin.core 2 uses pytest_unconfigure to unmount wcfs
servers that it spawned:

https://lab.nexedi.com/kirr/wendelin.core/blob/1be4d730/conftest.py#L27-53

This usually leads to some test as shown in added test.

-> Skip that text backwards and actually detect pytest summary line
instead of returning empty dict, because empty dict forces Nexedi ERP5
to treat such test run to have UNKNOWN status, e.g.

https://erp5.nexedi.net/test_result_module/20201108-C170850/11

/cc @jerome
/reviewed-on !5
parent 549cc2f6
...@@ -351,12 +351,19 @@ class LocalTestResultLine: ...@@ -351,12 +351,19 @@ class LocalTestResultLine:
class PyTest: class PyTest:
@staticmethod @staticmethod
def summary(out): # -> status_dict def summary(out): # -> status_dict
# last line is like # end of output is like
# ================ 1 failed, 1 passed, 12 skipped in 0.39 seconds ================ # ================ 1 failed, 1 passed, 12 skipped in 0.39 seconds ================
# ...
textv = out.splitlines() textv = out.splitlines()
tail = textv[-1] for l in reversed(textv):
if re.match(b'^====* .* ====*$', l):
pytail = l
break
else:
return {}
def get(name, default=None): def get(name, default=None):
m = re.search(r'\b([0-9]+) '+name+r'\b', tail) m = re.search(r'\b([0-9]+) '+name+r'\b', pytail)
if m is None: if m is None:
return default return default
return int(m.group(1)) return int(m.group(1))
......
...@@ -114,6 +114,24 @@ golang/time_test.py:106: AssertionError ...@@ -114,6 +114,24 @@ golang/time_test.py:106: AssertionError
""", """,
'?\ttestname\t1.000s\t# 112t ?e 1f 13s') '?\ttestname\t1.000s\t# 112t ?e 1f 13s')
case1('ok+tailtext', """\
date: Sun, 08 Nov 2020 12:26:24 MSK
xnode: kirr@deco.navytux.spb.ru
uname: Linux deco 5.9.0-1-amd64 #1 SMP Debian 5.9.1-1 (2020-10-17) x86_64
cpu: Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
>>> test.py/fs-wcfs:
$ make test.py # GOMAXPROCS= WENDELIN_CORE_TEST_DB=<fs> WENDELIN_CORE_VIRTMEM=r:wcfs+w:uvmm
...
==================== 54 passed, 1 xpassed in 13.47 seconds =====================
# unmount/stop wcfs pid39670 @ /tmp/wcfs/cff0a836e51839ee7b10ba76277c639fe11bdb11
wcfs: 2020/11/08 12:26:38 /tmp/testdb_fs.Z9IvT0/1.fs: watcher: stat /tmp/testdb_fs.Z9IvT0/1.fs: use of closed file
# 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
""",
'?\ttestname\t1.000s\t# 55t ?e ?f ?s')
@pytest.mark.parametrize("name,textout,summaryok", testv) @pytest.mark.parametrize("name,textout,summaryok", testv)
def test_pytest_summary(name,textout, summaryok): def test_pytest_summary(name,textout, summaryok):
......
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