def run(self, script, target=None) -> subprocess.CompletedProcess:
path, script = self.write_script(script)
cmd = [self.make_exe, '-f', str(path)]
if target:
cmd.append(target)
res = subprocess.run(cmd, cwd=str(self.tmpdir), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
exit_nok = res.returncode not in self.valid_exit_codes
output_nok = b'Syntax error' in res.stderr or b'ERROR' in res.stderr
if exit_nok or output_nok:
pytest.fail(self.format_error(script, res))
return res
评论列表
文章目录