python: fix non-determinism in the test suite.
Some tests calling spot.automaton('non-existing|') where failing either
with a "process returned 127", or, under heavier load, with "failed to
read from...". The latter occur if we poll() the exit status before the
children has had the tame to finish.
* wrap/python/spot.py: Make sure we wait for the child process if we
reach EOF, so that we can report the error status.
* wrap/python/tests/automata-io.ipynb, wrap/python/tests/piperead.ipynb:
Update.
This commit is contained in:
parent
ebdb5b7c90
commit
39b92a6dea
3 changed files with 55 additions and 43 deletions
|
|
@ -147,16 +147,25 @@ def automata(*filenames):
|
|||
p = hoa_stream_parser(proc.stdout.fileno(), filename, True)
|
||||
a = True
|
||||
while a:
|
||||
# This returns None when we reach the end of the file.
|
||||
a = p.parse_strict(_bdd_dict)
|
||||
if a:
|
||||
yield a
|
||||
finally:
|
||||
# Make sure we destroy the parser and the subprocess in
|
||||
# the correct order...
|
||||
# Make sure we destroy the parser (p) and the subprocess
|
||||
# (prop) in the correct order...
|
||||
del p
|
||||
if proc != None:
|
||||
proc.poll()
|
||||
ret = proc.returncode
|
||||
if not a:
|
||||
# We reached the end of the stream. Wait for the
|
||||
# process to finish, so that we can its exit code.
|
||||
ret = proc.wait()
|
||||
else:
|
||||
# if a != None, we probably got there through an
|
||||
# exception, and the subprocess my still be
|
||||
# running. Check if an exit status is available
|
||||
# just in case.
|
||||
ret = proc.poll()
|
||||
del proc
|
||||
if ret:
|
||||
raise RuntimeError("Command {} exited with exit status {}"
|
||||
|
|
@ -166,7 +175,7 @@ def automata(*filenames):
|
|||
def automaton(filename):
|
||||
"""Read a single automaton from a file.
|
||||
|
||||
See `spot.automata()` for a list of supported format."""
|
||||
See `spot.automata()` for a list of supported formats."""
|
||||
try:
|
||||
return next(automata(filename))
|
||||
except StopIteration:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue