Skip to content

Commit f2a3abc

Browse files
committed
wasm: Skip more subprocess & thread tests
1 parent 94c0924 commit f2a3abc

File tree

9 files changed

+27
-8
lines changed

9 files changed

+27
-8
lines changed

lib/matplotlib/animation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ def bin_path(cls):
360360
@classmethod
361361
def isAvailable(cls):
362362
"""Return whether a MovieWriter subclass is actually available."""
363+
if sys.platform == 'emscripten':
364+
return False
363365
return shutil.which(cls.bin_path()) is not None
364366

365367

lib/matplotlib/dviread.py

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

10711071
try:
10721072
lk = _LuatexKpsewhich()
1073-
except FileNotFoundError:
1073+
except (FileNotFoundError, OSError):
10741074
lk = None # Fallback to directly calling kpsewhich, as below.
10751075

10761076
if lk:
@@ -1090,7 +1090,7 @@ def find_tex_file(filename):
10901090
path = (cbook._check_and_log_subprocess(['kpsewhich', filename],
10911091
_log, **kwargs)
10921092
.rstrip('\n'))
1093-
except (FileNotFoundError, RuntimeError):
1093+
except (FileNotFoundError, OSError, RuntimeError):
10941094
path = None
10951095

10961096
if path:

lib/matplotlib/testing/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ def subprocess_run_for_testing(command, env=None, timeout=60, stdout=None,
8888
pytest.xfail
8989
If platform is Cygwin and subprocess reports a fork() failure.
9090
"""
91+
if sys.platform == 'emscripten':
92+
import pytest
93+
pytest.skip('emscripten does not support subprocesses')
9194
if capture_output:
9295
stdout = stderr = subprocess.PIPE
9396
try:
@@ -175,7 +178,7 @@ def _has_tex_package(package):
175178
try:
176179
mpl.dviread.find_tex_file(f"{package}.sty")
177180
return True
178-
except FileNotFoundError:
181+
except (FileNotFoundError, OSError):
179182
return False
180183

181184

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
@@ -278,6 +278,8 @@ def test_no_length_frames(anim):
278278
anim.save('unused.null', writer=NullMovieWriter())
279279

280280

281+
@pytest.mark.skipif(sys.platform == 'emscripten',
282+
reason='emscripten does not support subprocesses')
281283
def test_movie_writer_registry():
282284
assert len(animation.writers._registered) > 0
283285
mpl.rcParams['animation.ffmpeg_path'] = "not_available_ever_xxxx"
@@ -546,6 +548,8 @@ def test_disable_cache_warning(anim):
546548
def test_movie_writer_invalid_path(anim):
547549
if sys.platform == "win32":
548550
match_str = r"\[WinError 3] .*'\\\\foo\\\\bar\\\\aardvark'"
551+
elif sys.platform == "emscripten":
552+
match_str = r"\[Errno 44] .*'/foo"
549553
else:
550554
match_str = r"\[Errno 2] .*'/foo"
551555
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
import matplotlib.dviread as dr
67
import pytest
@@ -60,7 +61,7 @@ def test_PsfontsMap(monkeypatch):
6061
fontmap[b'%']
6162

6263

63-
@pytest.mark.skipif(shutil.which("kpsewhich") is None,
64+
@pytest.mark.skipif(sys.platform == "emscripten" or shutil.which("kpsewhich") is None,
6465
reason="kpsewhich is not available")
6566
def test_dviread():
6667
dirpath = Path(__file__).parent / 'baseline_images/dviread'

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
@@ -1605,6 +1606,8 @@ def test_add_axes_kwargs():
16051606
plt.close()
16061607

16071608

1609+
@pytest.mark.skipif(sys.platform == 'emscripten',
1610+
reason='emscripten does not support threads')
16081611
def test_ginput(recwarn): # recwarn undoes warn filters at exit.
16091612
warnings.filterwarnings("ignore", "cannot show the figure")
16101613
fig, ax = plt.subplots()
@@ -1627,6 +1630,8 @@ def multi_presses():
16271630
np.testing.assert_allclose(fig.ginput(3), [(.3, .4), (.5, .6)])
16281631

16291632

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

lib/matplotlib/tests/test_font_manager.py

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

230230

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

lib/matplotlib/texmanager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,6 @@ def _run_checked_subprocess(cls, command, tex, *, cwd=None):
247247
report = subprocess.check_output(
248248
command, cwd=cwd if cwd is not None else cls._texcache,
249249
stderr=subprocess.STDOUT)
250-
except FileNotFoundError as exc:
251-
raise RuntimeError(
252-
f'Failed to process string with tex because {command[0]} '
253-
'could not be found') from exc
254250
except subprocess.CalledProcessError as exc:
255251
raise RuntimeError(
256252
'{prog} was not able to process the following string:\n'
@@ -263,6 +259,10 @@ def _run_checked_subprocess(cls, command, tex, *, cwd=None):
263259
tex=tex.encode('unicode_escape'),
264260
exc=exc.output.decode('utf-8', 'backslashreplace'))
265261
) from None
262+
except (FileNotFoundError, OSError) as exc:
263+
raise RuntimeError(
264+
f'Failed to process string with tex because {command[0]} '
265+
'could not be found') from exc
266266
_log.debug(report)
267267
return report
268268

0 commit comments

Comments
 (0)