The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit b43f4d00 authored by di68kap's avatar di68kap
Browse files

- test/run.py: changed calling of doctests to avoid errors with cythonized modules

parent 90c4dcc5
#cython: infer_types=True
#cython: language_level=3
#cython: c_string_type=unicode
#cython: c_string_encoding=utf-8
import cython
cdef class Error:
cdef str message
cdef int _pos
cdef object code
cdef int orig_pos
cdef int line
cdef int column
......@@ -4,8 +4,6 @@
#cython: c_string_encoding=utf-8
import cython
from DHParser cimport syntaxtree
# cdef class ParserError(Exception):
# cdef bint first_throw
......
......@@ -16,7 +16,8 @@ setup(
version=__version__,
packages=['DHParser'],
ext_modules=cythonize(['DHParser/stringview.py', 'DHParser/syntaxtree.py',
'DHParser/parse.py', 'DHParser/transform.py']),
'DHParser/parse.py', 'DHParser/transform.py',
'DHParser/error.py']),
url='https://gitlab.lrz.de/badw-it/DHParser',
license='[Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0)',
author='Eckhart Arnold',
......
......@@ -3,25 +3,29 @@
"""Runs the dhparser test-suite with several installed interpreters"""
import concurrent.futures
import doctest
import multiprocessing
import os
import platform
import time
def run_tests(command):
testtype = 'DOCTEST' if command.find('doctest') >= 0 else 'UNITTEST'
def run_doctests(module):
namespace = {}
exec('import DHParser.' + module, namespace)
mod = getattr(namespace['DHParser'], module)
result = doctest.testmod(mod)
return result.failed
def run_unittests(command):
filename = command[command.rfind(' ') + 1:]
print('\n' + testtype + ' ' + filename)
print('\nUNITTEST ' + filename)
os.system(command)
if __name__ == "__main__":
scriptdir = os.path.dirname(os.path.realpath(__file__))
# if os.getcwd().endswith('test'):
# os.chdir('..')
# print("Running nosetests:")
# os.system("nosetests test")
if platform.system() != "Windows":
interpreters = ['pypy3 ', 'python3 ']
else:
......@@ -32,20 +36,27 @@ if __name__ == "__main__":
timestamp = time.time()
run_doctests('toolkit')
with concurrent.futures.ProcessPoolExecutor(multiprocessing.cpu_count()) as pool:
for interpreter in interpreters:
os.system(interpreter + '--version')
results = []
# doctests
commands = [interpreter + ' -m doctest ' + os.path.join('DHParser', filename)
for filename in os.listdir('DHParser') if filename.endswith('.py')
and filename not in ["foreign_typing.py", "stringview.py", "__init__.py"]]
# doctests
for filename in os.listdir('DHParser'):
if filename.endswith('.py') and filename not in \
("foreign_typing.py", "shadow_cython.py", "versionnumber.py",
"__init__.py"):
results.append(pool.submit(run_doctests, filename[:-3]))
# unit tests
commands += [interpreter + os.path.join('test', filename)
for filename in os.listdir('test') if filename.startswith('test_')]
# unit tests
for interpreter in interpreters:
os.system(interpreter + '--version')
for filename in os.listdir('test'):
if filename.startswith('test_'):
command = interpreter + os.path.join('test', filename)
results.append(pool.submit(run_unittests, command))
pool.map(run_tests, commands)
concurrent.futures.wait(results)
elapsed = time.time() - timestamp
print('\n Test-Duration: %.2f seconds' % elapsed)
......
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