api_coverage.py: Add detection for changed func return value

This commit is contained in:
Kai Huuhko 2014-09-15 15:26:41 +03:00
parent 71371c00e0
commit 6b6788c12c
1 changed files with 25 additions and 11 deletions

View File

@ -114,12 +114,14 @@ def pkg_config(require, min_vers=None):
def get_capis(inc_path, prefix):
capirets = []
capis = []
capilns = []
capi_pattern = re.compile(
"^ *EAPI [A-Za-z_ *\n]+ *\**\n?(?!" +
c_excludes + ")(" + prefix +
"_\w+) *\(",
"^ *EAPI " +
"([A-Za-z_ *\n]+)[ *]*\n?" +
"(?!" + c_excludes + ")" +
"(" + prefix + "_\w+)" + " *\(",
flags=re.S | re.M
)
@ -143,24 +145,29 @@ def get_capis(inc_path, prefix):
i += len(line)
matches = re.finditer(capi_pattern, capi)
for match in matches:
func = match.group(1)
funcret = match.group(1)
funcname = match.group(2)
start = match.start()
line_n = line_starts.index(start) + 1
capilns.append((f, line_n))
capis.append(func)
capirets.append(funcret)
capis.append(funcname)
return capilns, capis
return capilns, capirets, capis
def get_pyapis(pxd_path, header_name, prefix):
pyapilns = []
pyapirets = []
pyapis = []
pyapi_pattern1 = re.compile(
'cdef extern from "' + header_name + '\.h":\n(.+)',
flags=re.S
)
pyapi_pattern2 = re.compile(
"^ +[a-zA-Z _*]+?(?!" + py_excludes + ")(" + prefix + "_\w+)\(",
"^ +([a-zA-Z _*]+?)" +
"(?!" + py_excludes + ")" +
"(" + prefix + "_\w+)" + "\(",
flags=re.M
)
@ -186,13 +193,15 @@ def get_pyapis(pxd_path, header_name, prefix):
i += len(line)
matches = re.finditer(pyapi_pattern2, cdef.group(1))
for match in matches:
func = match.group(1)
funcret = match.group(1)
func = match.group(2)
start = match.start() + offset
line_n = line_starts.index(start) + 1
pyapilns.append((f, line_n))
pyapirets.append(funcret)
pyapis.append(func)
return pyapilns, pyapis
return pyapilns, pyapirets, pyapis
rows, columns = os.popen('stty size', 'r').read().split()
@ -218,8 +227,13 @@ for lib in args.libs:
pxd_path, header_name, prefix = params[lib]
c_api_line_ns, c_apis = get_capis(inc_path, prefix)
py_api_line_ns, py_apis = get_pyapis(pxd_path, header_name, prefix)
c_api_line_ns, c_api_rets, c_apis = get_capis(inc_path, prefix)
py_api_line_ns, py_api_rets, py_apis = get_pyapis(pxd_path, header_name, prefix)
rets = zip(c_api_line_ns, c_api_rets, py_api_line_ns, py_api_rets)
for cln, cret, pyln, pyret in rets:
if cret != pyret:
print("SIGNATURE DIFFERS BETWEEN %s: %s AND %s: %s !!!" % (cln, cret, pyln, pyret))
capis = set(c_apis)
pyapis = set(py_apis)