Skip to content

Commit 94159f9

Browse files
committed
wasm: Skip more subprocess & thread tests
1 parent b0908d2 commit 94159f9

File tree

9 files changed

+29
-8
lines changed

9 files changed

+29
-8
lines changed

lib/matplotlib/animation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,8 @@ def bin_path(cls):
369369
@classmethod
370370
def isAvailable(cls):
371371
"""Return whether a MovieWriter subclass is actually available."""
372+
if sys.platform == 'emscripten':
373+
return False
372374
return shutil.which(cls.bin_path()) is not None
373375

374376

lib/matplotlib/dviread.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ def find_tex_file(filename):
12971297

12981298
try:
12991299
lk = _LuatexKpsewhich()
1300-
except FileNotFoundError:
1300+
except (FileNotFoundError, OSError):
13011301
lk = None # Fallback to directly calling kpsewhich, as below.
13021302

13031303
if lk:
@@ -1320,7 +1320,7 @@ def find_tex_file(filename):
13201320
path = cbook._check_and_log_subprocess(
13211321
['kpsewhich', '-mktex=pk', filename], _log, **kwargs,
13221322
).rstrip('\n')
1323-
except (FileNotFoundError, RuntimeError):
1323+
except (FileNotFoundError, OSError, RuntimeError):
13241324
path = None
13251325

13261326
if path:

lib/matplotlib/testing/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,14 @@ def subprocess_run_for_testing(command, env=None, timeout=60, stdout=None,
8787
8888
Raises
8989
------
90+
pytest.skip
91+
If running on emscripten, which does not support subprocesses.
9092
pytest.xfail
9193
If platform is Cygwin and subprocess reports a fork() failure.
9294
"""
95+
if sys.platform == 'emscripten':
96+
import pytest
97+
pytest.skip('emscripten does not support subprocesses')
9398
if capture_output:
9499
stdout = stderr = subprocess.PIPE
95100
try:
@@ -187,7 +192,7 @@ def _has_tex_package(package):
187192
try:
188193
mpl.dviread.find_tex_file(f"{package}.sty")
189194
return True
190-
except FileNotFoundError:
195+
except (FileNotFoundError, OSError):
191196
return False
192197

193198

lib/matplotlib/testing/decorators.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ def copy_baseline(self, baseline, extension):
138138
try:
139139
if 'microsoft' in uname().release.lower():
140140
raise OSError # On WSL, symlink breaks silently
141+
if sys.platform == 'emscripten':
142+
raise OSError
141143
os.symlink(orig_expected_path, expected_fname)
142144
except OSError: # On Windows, symlink *may* be unavailable.
143145
shutil.copyfile(orig_expected_path, expected_fname)

lib/matplotlib/tests/test_animation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ def test_no_length_frames(anim):
271271
anim.save('unused.null', writer=NullMovieWriter())
272272

273273

274+
@pytest.mark.skipif(sys.platform == 'emscripten',
275+
reason='emscripten does not support subprocesses')
274276
def test_movie_writer_registry():
275277
assert len(animation.writers._registered) > 0
276278
mpl.rcParams['animation.ffmpeg_path'] = "not_available_ever_xxxx"
@@ -522,6 +524,8 @@ def test_disable_cache_warning(anim):
522524
def test_movie_writer_invalid_path(anim):
523525
if sys.platform == "win32":
524526
match_str = r"\[WinError 3] .*\\\\foo\\\\bar\\\\aardvark'"
527+
elif sys.platform == "emscripten":
528+
match_str = r"\[Errno 44] .*'/foo"
525529
else:
526530
match_str = r"\[Errno 2] .*'/foo"
527531
with pytest.raises(FileNotFoundError, match=match_str):

lib/matplotlib/tests/test_dviread.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
from pathlib import Path
33
import shutil
4+
import sys
45

56
from matplotlib import cbook, dviread as dr
67
from matplotlib.testing import subprocess_run_for_testing, _has_tex_package
@@ -61,7 +62,7 @@ def test_PsfontsMap(monkeypatch):
6162
fontmap[b'%']
6263

6364

64-
@pytest.mark.skipif(shutil.which("kpsewhich") is None,
65+
@pytest.mark.skipif(sys.platform == "emscripten" or shutil.which("kpsewhich") is None,
6566
reason="kpsewhich is not available")
6667
@pytest.mark.parametrize("engine", ["pdflatex", "xelatex", "lualatex"])
6768
def test_dviread(tmp_path, engine, monkeypatch):

lib/matplotlib/tests/test_figure.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io
44
import pickle
55
import platform
6+
import sys
67
from threading import Timer
78
from types import SimpleNamespace
89
import warnings
@@ -1603,6 +1604,8 @@ def test_add_axes_kwargs():
16031604
plt.close()
16041605

16051606

1607+
@pytest.mark.skipif(sys.platform == 'emscripten',
1608+
reason='emscripten does not support threads')
16061609
def test_ginput(recwarn): # recwarn undoes warn filters at exit.
16071610
warnings.filterwarnings("ignore", "cannot show the figure")
16081611
fig, ax = plt.subplots()
@@ -1625,6 +1628,8 @@ def multi_presses():
16251628
np.testing.assert_allclose(fig.ginput(3), [(.3, .4), (.5, .6)])
16261629

16271630

1631+
@pytest.mark.skipif(sys.platform == 'emscripten',
1632+
reason='emscripten does not support threads')
16281633
def test_waitforbuttonpress(recwarn): # recwarn undoes warn filters at exit.
16291634
warnings.filterwarnings("ignore", "cannot show the figure")
16301635
fig = plt.figure()

lib/matplotlib/tests/test_font_manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ def _model_handler(_):
229229
plt.close()
230230

231231

232+
@pytest.mark.skipif(sys.platform == 'emscripten',
233+
reason='emscripten does not support subprocesses')
232234
@pytest.mark.skipif(not hasattr(os, "register_at_fork"),
233235
reason="Cannot register at_fork handlers")
234236
def test_fork():

lib/matplotlib/texmanager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,6 @@ def _run_checked_subprocess(cls, command, tex, *, cwd=None):
258258
report = subprocess.check_output(
259259
command, cwd=cwd if cwd is not None else cls._cache_dir,
260260
stderr=subprocess.STDOUT)
261-
except FileNotFoundError as exc:
262-
raise RuntimeError(
263-
f'Failed to process string with tex because {command[0]} '
264-
'could not be found') from exc
265261
except subprocess.CalledProcessError as exc:
266262
raise RuntimeError(
267263
'{prog} was not able to process the following string:\n'
@@ -274,6 +270,10 @@ def _run_checked_subprocess(cls, command, tex, *, cwd=None):
274270
tex=tex.encode('unicode_escape'),
275271
exc=exc.output.decode('utf-8', 'backslashreplace'))
276272
) from None
273+
except (FileNotFoundError, OSError) as exc:
274+
raise RuntimeError(
275+
f'Failed to process string with tex because {command[0]} '
276+
'could not be found') from exc
277277
_log.debug(report)
278278
return report
279279

0 commit comments

Comments
 (0)