Commit 02d86d70 authored by Stefan Behnel's avatar Stefan Behnel

extend nogil coverage test

parent f4d42e80
...@@ -26,19 +26,22 @@ plugins = Cython.Coverage ...@@ -26,19 +26,22 @@ plugins = Cython.Coverage
# distutils: define_macros=CYTHON_TRACE=1 # distutils: define_macros=CYTHON_TRACE=1
cdef int func1(int a, int b) nogil: cdef int func1(int a, int b) nogil:
cdef int x = 1 # 5 cdef int x # 5
cdef int c = func2(a) + b # 6 with gil: # 6
return x + c # 7 x = 1 # 7
cdef int c = func2(a) + b # 8
return x + c # 9
cdef int func2(int a) with gil: cdef int func2(int a) with gil:
return a * 2 # 11 return a * 2 # 13
def call(int a, int b): def call(int a, int b):
with nogil: # 15 a, b = b, a # 17
result = func1(a, b) # 16 with nogil: # 18
return result # 17 result = func1(b, a) # 19
return result # 20
######## coverage_test.py ######## ######## coverage_test.py ########
...@@ -81,8 +84,9 @@ def run_coverage(module): ...@@ -81,8 +84,9 @@ def run_coverage(module):
executed = set(exec_lines) - set(missing_lines) executed = set(exec_lines) - set(missing_lines)
# check that everything that runs with the gil owned was executed # check that everything that runs with the gil owned was executed
assert all(line in executed for line in [11, 15, 17]), '%s / %s' % (exec_lines, missing_lines) assert all(line in executed for line in [13, 17, 18, 20]), '%s / %s' % (exec_lines, missing_lines)
# currently, we do not trace nogil code lines, but that should eventually be implemented # currently, we do not trace nogil code lines, but that should eventually be implemented
# we also don't trace 'with gil' blocks in 'nogil' functions
if __name__ == '__main__': if __name__ == '__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