When latex fails, make sure it does not write a dvi. #10348
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR #10180 added some tests checking that when the latex subprocess used
by usetex fails, a RuntimeError does propagate up to the Python process.
It originally passed the CI, but since its merge, various CIs have been
failing on the test that a text with
$22_2_2$
(an invalid texconstruct) fails when usetex is set.
This is because while
latex --interaction=nonstopmode
does exit witherror code 1 when processing a file with that construct, the error is
"benign" enough that it still writes a dvi before exiting (the contents
are simply as if the input was
$22_{22}$
). The dvi goes into the texcache and later CI runs pick up the cached dvi instead of running the
subprocess, thus failing the test.
The solution is to use --halt-on-error on top of nonstopmode, see e.g.
https://tex.stackexchange.com/questions/258814/what-is-the-difference-between-interaction-nonstopmode-and-halt-on-error (and to clear your tex cache).
Note that before the PR, there would similarly be the weird behavior
(for the user) that the first attempt to use a "benignly" invalid tex
construct would trigger an exception, but latter attempts would not (for
the same reason as above).
attn @efiring
labeling as rc as it's a CI issue.
PR Summary
PR Checklist