extracttests.py: added docstrings. added navigation links.
This commit is contained in:
parent
db186b2c25
commit
0c54f88dd0
|
@ -1,12 +1,19 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
"""Extract test cases information from Cppcheck test file"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
|
||||||
class Extract:
|
class Extract:
|
||||||
|
"""Read Cppcheck test file and create data representation"""
|
||||||
|
|
||||||
|
# array that stores all the test cases
|
||||||
nodes = []
|
nodes = []
|
||||||
|
|
||||||
def parseFile(self,filename):
|
def parseFile(self,filename):
|
||||||
|
"""parse test file and add info to the nodes variable"""
|
||||||
|
|
||||||
name = '[0-9a-zA-Z_]+'
|
name = '[0-9a-zA-Z_]+'
|
||||||
str = '\\"(.+)\\"'
|
str = '\\"(.+)\\"'
|
||||||
|
|
||||||
|
@ -53,9 +60,11 @@ class Extract:
|
||||||
code = ''
|
code = ''
|
||||||
|
|
||||||
def strtoxml(s):
|
def strtoxml(s):
|
||||||
|
"""Convert string to xml/html format"""
|
||||||
return s.replace('&','&').replace('"', '"').replace('<','<').replace('>','>')
|
return s.replace('&','&').replace('"', '"').replace('<','<').replace('>','>')
|
||||||
|
|
||||||
def trimname(name):
|
def trimname(name):
|
||||||
|
"""Trim test name. Trailing underscore and digits are removed"""
|
||||||
while name[-1].isdigit():
|
while name[-1].isdigit():
|
||||||
name = name[:-1]
|
name = name[:-1]
|
||||||
if name[-1] == '_':
|
if name[-1] == '_':
|
||||||
|
@ -64,6 +73,7 @@ def trimname(name):
|
||||||
|
|
||||||
|
|
||||||
def writeHtmlFile(nodes, functionName, filename, errorsOnly):
|
def writeHtmlFile(nodes, functionName, filename, errorsOnly):
|
||||||
|
"""Write html file for a function name"""
|
||||||
fout = open(filename, 'w')
|
fout = open(filename, 'w')
|
||||||
fout.write('<html>\n')
|
fout.write('<html>\n')
|
||||||
fout.write('<head>\n')
|
fout.write('<head>\n')
|
||||||
|
@ -76,6 +86,13 @@ def writeHtmlFile(nodes, functionName, filename, errorsOnly):
|
||||||
fout.write('</head>\n')
|
fout.write('</head>\n')
|
||||||
fout.write('<body>\n')
|
fout.write('<body>\n')
|
||||||
|
|
||||||
|
fout.write('<a href="index.htm">Home</a> -- ')
|
||||||
|
if errorsOnly:
|
||||||
|
fout.write('<a href="all-'+functionName+'.htm">All test cases</a>')
|
||||||
|
else:
|
||||||
|
fout.write('<a href="errors-'+functionName+'.htm">Error test cases</a>')
|
||||||
|
fout.write('<br><br>')
|
||||||
|
|
||||||
testclass = None
|
testclass = None
|
||||||
num = 0
|
num = 0
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
|
|
Loading…
Reference in New Issue