ltsmin-pml: work around newer jupyter versions

Newer Jupyter version are able to capture the system's stdout and
stderr to display it in the notebook.  This is done asynchronously,
with a thread polling those file descriptor.  While this will help us
debug (finaly we can see the tracing code we put in C++) this causes
two issues for testing.  One is the asynchronous behaviour, which
makes it very hard to reproduce notebooks.  The second issue is that
older version of Jupyter used to hide some of the prints from the
notebook, so it is hard to accommodate both.

In the case of the ltsmin-pml notebook, loading the PML file from
a filename used to trigger a compilation silently (with output on the
console, but not in the notebook).  The newer version had the output
of that compilation spread into two cells.

* python/spot/ltsmin.i: Work around the issue by triggering the
compilation from Python, and capturing its output explicitly, so it
work with all Jupyter versions.  Also adjust to use the more recent
and simpler subprocess.run() interface, available since Python 3.5.
* tests/python/ltsmin-pml.ipynb: Adjust expected output.
* tests/python/ipnbdoctest.py (canonicalize): Adjust patterns.
This commit is contained in:
Alexandre Duret-Lutz 2021-11-15 23:37:08 +01:00
parent aeb05f0ff0
commit 186d206302
3 changed files with 103 additions and 182 deletions

View file

@ -93,7 +93,9 @@ def canonicalize(s, type, ignores):
s = re.sub(r'Generated by graphviz version.*', 'VERSION', s)
# remove Spins verbose output version
s = re.sub(r'SpinS Promela Compiler.*Compiled C .* to .*pml.spins',
s = re.sub(r'SpinS Promela Compiler.*Written C .* to .*pml.spins.c',
'SpinS output', s, flags=re.DOTALL)
s = re.sub(r'Compiled C code to PINS .*pml.spins',
'SpinS output', s, flags=re.DOTALL)
# %%file writes `Writing`, or `Overwriting` if the file exists.
@ -298,7 +300,8 @@ def test_notebook(ipynb):
km = KernelManager()
# Do not save the history to disk, as it can yield spurious lock errors.
# See https://github.com/ipython/ipython/issues/2845
km.start_kernel(extra_arguments=['--HistoryManager.hist_file=:memory:'])
km.start_kernel(extra_arguments=['--HistoryManager.hist_file=:memory:',
'--quiet'])
kc = km.client()
kc.start_channels()