Commit 321027be authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 67b0680c
# setup for continous integration via nxdtes # setup to run neotest on Nexedi testing infrastructure.
# https://stack.nexedi.com/test_status
# xint converts number from neo/py test output to integer
def xint(s):
s = s.strip()
if s == '.':
return 0
else:
return int(s)
# extract summary from neo/py test run
def test_py_summary(stdout):
# Test Module | run | unexpected | expected | skipped | time
# ...
# Summary | 366 | . | 9 | . | 353.47s
m = re.search(r'^\s*summary.*$', stdout, re.M | re.I)
assert m is not None, "could not find summary line"
summary = m.group(0)
_, nrun, nfail, nxfail, nskip, _ = summary.split('|')
return {
'test_count': xint(nrun),
'error_count': xint(nfail),
'failure_count': xint(nxfail),
'skip_count': xint(nskip),
}
TestCase('test-go', ['neotest', 'test-go']) TestCase('test-go', ['neotest', 'test-go'])
TestCase('test-py', ['neotest', 'test-py']) TestCase('test-py', ['neotest', 'test-py'], summaryf=test_py_summary)
TestCase('bench-local', ['neotest', 'bench-local']) TestCase('bench-local', ['neotest', 'bench-local'])
...@@ -43,10 +43,11 @@ def loadNXDTestFile(path): # -> TestEnv ...@@ -43,10 +43,11 @@ def loadNXDTestFile(path): # -> TestEnv
# TestCase defines one test case to run. # TestCase defines one test case to run.
class TestCase: class TestCase:
def __init__(self, name, argv, **kw): def __init__(self, name, argv, summaryf=None, **kw):
self.name = name self.name = name
self.argv = argv self.argv = argv
self.kw = kw self.kw = kw
self.summaryf = summaryf
# TestEnv represents a testing environment with set of TestCases to run. # TestEnv represents a testing environment with set of TestCases to run.
class TestEnv: class TestEnv:
...@@ -157,10 +158,9 @@ def main(): ...@@ -157,10 +158,9 @@ def main():
status['error_count'] += 1 status['error_count'] += 1
# postprocess output, if we can # postprocess output, if we can
summaryf = globals().get(t.name.replace('-', '_') + '_summary') if t.summaryf is not None:
if summaryf is not None:
try: try:
summary = summaryf(stdout) summary = t.summaryf(stdout)
except: except:
bad = traceback.format_exc() bad = traceback.format_exc()
sys.stderr.write(bad) sys.stderr.write(bad)
...@@ -237,32 +237,5 @@ class LocalTestResultLine: ...@@ -237,32 +237,5 @@ class LocalTestResultLine:
print('%s\t%s\t%.3fs\t# %st %se %sf %ss' % (st, self.name, kw['duration'], v('test_count'), v('error_count'), v('failure_count'), v('skip_count'))) print('%s\t%s\t%.3fs\t# %st %se %sf %ss' % (st, self.name, kw['duration'], v('test_count'), v('error_count'), v('failure_count'), v('skip_count')))
# xint converts number from neo/py test output to integer
def xint(s):
s = s.strip()
if s == '.':
return 0
else:
return int(s)
# extract summary from neo/py test run
def test_py_summary(stdout):
# Test Module | run | unexpected | expected | skipped | time
# ...
# Summary | 366 | . | 9 | . | 353.47s
m = re.search(r'^\s*summary.*$', stdout, re.M | re.I)
assert m is not None, "could not find summary line"
summary = m.group(0)
_, nrun, nfail, nxfail, nskip, _ = summary.split('|')
return {
'test_count': xint(nrun),
'error_count': xint(nfail),
'failure_count': xint(nxfail),
'skip_count': xint(nskip),
}
if __name__ == '__main__': if __name__ == '__main__':
main() main()
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