Skip to content

Commit dfde391

Browse files
committed
wasm: Skip more subprocess & thread tests
1 parent 57f0b1c commit dfde391

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
@@ -368,6 +368,8 @@ def bin_path(cls):
368368
@classmethod
369369
def isAvailable(cls):
370370
"""Return whether a MovieWriter subclass is actually available."""
371+
if sys.platform == 'emscripten':
372+
return False
371373
return shutil.which(cls.bin_path()) is not None
372374

373375

lib/matplotlib/dviread.py

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

11211121
try:
11221122
lk = _LuatexKpsewhich()
1123-
except FileNotFoundError:
1123+
except (FileNotFoundError, OSError):
11241124
lk = None # Fallback to directly calling kpsewhich, as below.
11251125

11261126
if lk:
@@ -1140,7 +1140,7 @@ def find_tex_file(filename):
11401140
path = (cbook._check_and_log_subprocess(['kpsewhich', filename],
11411141
_log, **kwargs)
11421142
.rstrip('\n'))
1143-
except (FileNotFoundError, RuntimeError):
1143+
except (FileNotFoundError, OSError, RuntimeError):
11441144
path = None
11451145

11461146
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:
@@ -177,7 +182,7 @@ def _has_tex_package(package):
177182
try:
178183
mpl.dviread.find_tex_file(f"{package}.sty")
179184
return True
180-
except FileNotFoundError:
185+
except (FileNotFoundError, OSError):
181186
return False
182187

183188

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
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
@@ -250,10 +250,6 @@ def _run_checked_subprocess(cls, command, tex, *, cwd=None):
250250
report = subprocess.check_output(
251251
command, cwd=cwd if cwd is not None else cls._texcache,
252252
stderr=subprocess.STDOUT)
253-
except FileNotFoundError as exc:
254-
raise RuntimeError(
255-
f'Failed to process string with tex because {command[0]} '
256-
'could not be found') from exc
257253
except subprocess.CalledProcessError as exc:
258254
raise RuntimeError(
259255
'{prog} was not able to process the following string:\n'
@@ -266,6 +262,10 @@ def _run_checked_subprocess(cls, command, tex, *, cwd=None):
266262
tex=tex.encode('unicode_escape'),
267263
exc=exc.output.decode('utf-8', 'backslashreplace'))
268264
) from None
265+
except (FileNotFoundError, OSError) as exc:
266+
raise RuntimeError(
267+
f'Failed to process string with tex because {command[0]} '
268+
'could not be found') from exc
269269
_log.debug(report)
270270
return report
271271

0 commit comments

Comments
 (0)