MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / parseFile

Method parseFile

test/scripts/extracttests.py:82–166  ·  view source on GitHub ↗

parse test file and add info to the nodes variable

(self, filename)

Source from the content-addressed store, hash-verified

80 nodes = []
81
82 def parseFile(self, filename):
83 """
84 parse test file and add info to the nodes
85 variable
86 """
87
88 name = '[0-9a-zA-Z_]+'
89 string = '\\"(.+)\\"'
90
91 testclass = None
92 functionName = None
93 code = None
94 start_code = None
95 disable = False
96
97 for line in open(filename, 'r'):
98 # testclass starts
99 res = re.match('class (' + name + ')', line)
100 if res is not None:
101 testclass = res.group(1)
102
103 # end of testclass
104 if re.match('};', line) is not None:
105 testclass = None
106
107 # function start
108 res = re.match('\\s+void (' + name + ')\\(\\)', line)
109 if res is not None:
110 functionName = res.group(1)
111 start_code = None
112
113 elif re.match('\\s+}', line) is not None:
114 functionName = None
115
116 # extracttests commands..
117 res = re.match(r'\s*//\s*extracttests.start:(.*)', line)
118 if res is not None:
119 start_code = res.group(1).replace('\\n', '\n') + '\n'
120 elif line.find('extracttests.disable') >= 0:
121 disable = True
122 elif line.find('extracttests.enable') >= 0:
123 disable = False
124
125 if functionName is None or disable:
126 continue
127
128 # check
129 for f in check_function:
130 res = re.match('\\s+' + f + '\\(' + string, line)
131 if res is not None:
132 code = res.group(1)
133 break
134
135 # code..
136 if code is not None:
137 res = re.match('\\s+' + string, line)
138 if res is not None:
139 if line.find('",') > line.find('"'):

Callers 8

suppressionsBadId1Method · 0.45
suppressionsDosFormatMethod · 0.45
suppressionsGlobMethod · 0.45
suppressionsGlobIdMethod · 0.45
suppressLocalMethod · 0.45
extracttests.pyFile · 0.45

Calls 5

get_includesFunction · 0.85
tweak_expectedFunction · 0.85
matchMethod · 0.45
replaceMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected