(self, filedata=None)
| 57 | return p.communicate(timeout=timeout) |
| 58 | |
| 59 | def runtool(self, filedata=None): |
| 60 | TimeoutExpired = subprocess.TimeoutExpired |
| 61 | |
| 62 | timeout = None |
| 63 | if self.__elapsed_time: |
| 64 | timeout = self.__elapsed_time * 2 |
| 65 | p = subprocess.Popen(self.__cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) |
| 66 | try: |
| 67 | stdout, stderr = self.__communicate(p, timeout=timeout) |
| 68 | except TimeoutExpired: |
| 69 | print('timeout') |
| 70 | p.kill() |
| 71 | p.communicate() |
| 72 | if filedata: |
| 73 | self.writetimeoutfile(filedata) |
| 74 | return False |
| 75 | # print(p.returncode) |
| 76 | # print(comm) |
| 77 | if self.__segfault: |
| 78 | if p.returncode != 0: |
| 79 | return True |
| 80 | elif p.returncode == 0: |
| 81 | out = stdout + '\n' + stderr |
| 82 | if self.__expected in out: |
| 83 | return True |
| 84 | else: |
| 85 | # Something could be wrong, for example the command line for Cppcheck (CMD). |
| 86 | # Print the output to give a hint how to fix it. |
| 87 | print('Error: {}\n{}'.format(stdout, stderr)) |
| 88 | return False |
| 89 | |
| 90 | def __writefile(self, filename, filedata): |
| 91 | with open(filename, 'wt') as f: |
no test coverage detected