parse test file and add info to the nodes variable
(self, filename)
| 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('"'): |
no test coverage detected