diff --git a/programlib/language.py b/programlib/language.py index 6f17470..38039c4 100644 --- a/programlib/language.py +++ b/programlib/language.py @@ -24,12 +24,17 @@ def build(self, name): return '', '' def run(self, name, input_lines=[]): - child = self.spawn(name) - for line in input_lines: - child.sendline(line) - output = child.read() - child.close() - return output.decode(), child.exitstatus + try: + child = self.spawn(name) + for line in input_lines: + child.sendline(line) + output = child.read() + child.close() + return output.decode(), child.exitstatus + except pexpect.exceptions.TIMEOUT as e: + raise RuntimeError('Program did not receive expected input') from e + except pexpect.exceptions.EOF as e: + raise RuntimeError('Program exited unexpectedly') from e def spawn(self, name): child = pexpect.spawn(self.run_cmd.format(name=name)) diff --git a/programlib/program.py b/programlib/program.py index 30d74e8..e22a656 100644 --- a/programlib/program.py +++ b/programlib/program.py @@ -121,7 +121,7 @@ def test(self, test_cases, force=True): test_run = TestRun(input_lines, expected_output_lines, output_lines, self.exitstatus, correctness(expected_output_lines, output_lines)) - except AssertionError: + except (AssertionError, RuntimeError): pass if not test_run: diff --git a/pyproject.toml b/pyproject.toml index 890c6d5..ed9ba02 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "programlib" -version = "8.0.0" +version = "8.0.1" description = "Programs as Objects" authors = ["Vadim Liventsev "] license = "MIT"