Skip to content

Commit 26cbd0f

Browse files
authored
Check for empty output in llvm_interpret (#4773)
In case of a malformed input, this results in a meaningful error message even if `check=False`.
1 parent 0301a14 commit 26cbd0f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

pyk/src/pyk/ktool/krun.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,9 @@ def llvm_interpret(
445445
except CalledProcessError as err:
446446
raise RuntimeError(f'Interpreter failed with status {err.returncode}: {err.stderr}') from err
447447

448+
if not res.stdout:
449+
raise RuntimeError(f'Interpreter terminated with status {res.returncode} and produced no output: {res.stderr}')
450+
448451
return KoreParser(res.stdout).pattern()
449452

450453

pyk/src/tests/integration/test_krun.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pyk.kast.inner import KApply, KSequence, KSort, KToken, Subst
1010
from pyk.kore.parser import KoreParser
1111
from pyk.kore.prelude import inj, top_cell_initializer
12-
from pyk.kore.syntax import SortApp
12+
from pyk.kore.syntax import App, SortApp
1313
from pyk.ktool.kprint import _kast
1414
from pyk.ktool.krun import llvm_interpret
1515
from pyk.prelude.kint import intToken
@@ -128,3 +128,15 @@ def test_llvm_interpret(imp_definition: Path, a: int, b: int, expected: int) ->
128128

129129
# Then
130130
assert actual == expected
131+
132+
133+
def test_llvm_interpret_no_output(imp_definition: Path) -> None:
134+
# Given
135+
init_pattern = App('foo')
136+
137+
# When
138+
with pytest.raises(RuntimeError) as excinfo:
139+
llvm_interpret(imp_definition, init_pattern, depth=1000, check=False)
140+
141+
# Then
142+
assert 'produced no output' in str(excinfo.value)

0 commit comments

Comments
 (0)