Changeset: 4970ce7b1c1d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4970ce7b1c1d Modified Files: testing/exportutils.py testing/listexports.py.in testing/melcheck.py Branch: Oct2020 Log Message:
Fixes so that new code can be run for old (exports) test. diffs (110 lines): diff --git a/testing/exportutils.py b/testing/exportutils.py --- a/testing/exportutils.py +++ b/testing/exportutils.py @@ -17,7 +17,7 @@ inclre = re.compile(r'\s*#\s*include\s+" # comments (/* ... */ where ... is as short as possible) cmtre = re.compile(r'/\*[^*]*(\*(?=[^/])[^*]*)*\*/|//.*') # horizontal white space -spcre = re.compile(r'[ \t]+') +horspcre = re.compile(r'[ \t]+') # identifier identre = re.compile(r'\b(?P<ident>[a-zA-Z_]\w*)\b') # undef @@ -79,12 +79,12 @@ def process(line, funmac, macros, infunm nline += line[pos:] return nline -def readfile(f, funmac=None, macros=None, files=None, printdef=False): +def readfile(f, funmac=None, macros=None, files=None, printdef=False, include=False): data = open(f).read() dirname, f = os.path.split(f) data = cmtre.sub(' ', data) data = data.replace('\\\n', '') - data = spcre.sub(' ', data) + data = horspcre.sub(' ', data) data = data.splitlines() if funmac is None: funmac = {} @@ -110,7 +110,7 @@ def readfile(f, funmac=None, macros=None if elifre.match(line) or elsere.match(line): if printdef: ndata.append(line) - if skip: + if include and skip: skip[-1] = True continue if skip and skip[-1]: @@ -130,13 +130,14 @@ def readfile(f, funmac=None, macros=None args = () # empty argument list funmac[name] = (args, repl) continue - macros[name] = repl + if include: + macros[name] = repl continue res = inclre.match(line) if res is not None: fn = res.group('file') - if '/' not in fn and os.path.exists(os.path.join(dirname, fn)) and fn not in files: - incdata = readfile(os.path.join(dirname, fn), funmac, macros, files, printdef) + if include and '/' not in fn and os.path.exists(os.path.join(dirname, fn)) and fn not in files: + incdata = readfile(os.path.join(dirname, fn), funmac, macros, files, printdef, include) ndata.extend(incdata) continue ndata.append(line) @@ -154,8 +155,13 @@ def readfile(f, funmac=None, macros=None files.remove(f) return ndata -def preprocess(f, printdef=False): - return '\n'.join(readfile(f, printdef=printdef)) +def preprocess(f, printdef=False, include=True): + return '\n'.join(readfile(f, printdef=printdef, include=include)) + +# some regexps helping to normalize a declaration +spcre = re.compile(r'\s+') +strre = re.compile(r'([^ *])\*') +comre = re.compile(r',\s*') def normalize(decl): decl = spcre.sub(' ', decl) \ @@ -175,4 +181,4 @@ def normalize(decl): if __name__ == '__main__': import sys for f in sys.argv[1:]: - print(preprocess(f, printdef=True)) + print(preprocess(f, printdef=False)) diff --git a/testing/listexports.py.in b/testing/listexports.py.in --- a/testing/listexports.py.in +++ b/testing/listexports.py.in @@ -38,7 +38,7 @@ nmere = re.compile(r'\b(?P<name>[a-zA-Z_ def extract(f): decls = [] - data = exportutils.preprocess(f) + data = exportutils.preprocess(f, include=False) res = expre.search(data) while res is not None: @@ -81,8 +81,7 @@ def findfiles(dirlist, skipfiles = [], s decls.extend(extract(os.path.join(root, f))) done[f] = True decls.sort() - names, decls = list(zip(*decls)) - return decls + return [decl for name, decl in decls] def main(): for lib in libs: diff --git a/testing/melcheck.py b/testing/melcheck.py --- a/testing/melcheck.py +++ b/testing/melcheck.py @@ -76,7 +76,7 @@ def checkcommand(imp, mod, fcn, decl, re cpos = cres.end(0) def process1(f): - data = exportutils.preprocess(f) + data = exportutils.preprocess(f, include=True) pats = {} cmds = {} res = fcnre.search(data) _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list