8000 gh-90473: Misc test fixes for WASI by tiran · Pull Request #93218 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-90473: Misc test fixes for WASI #93218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Lib/distutils/tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class BuildTestCase(support.TempdirManager,
support.LoggingSilencer,
unittest.TestCase):

@unittest.skipUnless(sys.executable, "test requires sys.executable")
def test_finalize_options(self):
pkg_dir, dist = self.create_dist()
cmd = build(dist)
Expand Down
2 changes: 1 addition & 1 deletion Lib/lib2to3/tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_load_grammar_from_pickle(self):

@unittest.skipIf(sys.executable is None, 'sys.executable required')
@unittest.skipIf(
sys.platform == 'emscripten', 'requires working subprocess'
sys.platform in {'emscripten', 'wasi'}, 'requires working subprocess'
)
def test_load_grammar_from_subprocess(self):
tmpdir = tempfile.mkdtemp()
Expand Down
6 changes: 6 additions & 0 deletions Lib/test/test_netrc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import netrc, os, unittest, sys, textwrap
from test.support import os_helper, run_unittest

try:
import pwd
except ImportError:
pwd = None

temp_filename = os_helper.TESTFN

class NetrcTestCase(unittest.TestCase):
Expand Down Expand Up @@ -266,6 +271,7 @@ def test_comment_at_end_of_machine_line_pass_has_hash(self):


@unittest.skipUnless(os.name == 'posix', 'POSIX only test')
@unittest.skipIf(pwd is None, 'security check requires pwd module')
def test_security(self):
# This test is incomplete since we are normally not run as root and
# therefore can't test the file ownership being wrong.
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_os.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -1765,6 +1765,7 @@ def test_remove_nothing(self):
self.assertTrue(os.path.exists(os_helper.TESTFN))


@unittest.skipIf(support.is_wasi, "WASI has no /dev/null")
class DevNullTests(unittest.TestCase):
def test_devnull(self):
with open(os.devnull, 'wb', 0) as f:
Expand Down Expand Up @@ -2111,6 +2112,7 @@ def test_chmod(self):
self.assertRaises(OSError, os.chmod, os_helper.TESTFN, 0)


@unittest.skipIf(support.is_wasi, "Cannot create invalid FD on WASI.")
class TestInvalidFD(unittest.TestCase):
singles = ["fchdir", "dup", "fdatasync", "fstat",
"fstatvfs", "fsync", "tcgetpgrp", "ttyname"]
Expand Down
9 changes: 6 additions & 3 deletions Lib/test/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from unittest import mock

from test.support import import_helper
from test.support import is_emscripten
from test.support import is_emscripten, is_wasi
from test.support import os_helper
from test.support.os_helper import TESTFN, FakePath

Expand Down Expand Up @@ -1530,6 +1530,7 @@ def test_empty_path(self):
p = self.cls('')
self.assertEqual(p.stat(), os.stat('.'))

@unittest.skipIf(is_wasi, "WASI has no user accounts.")
def test_expanduser_common(self):
P = self.cls
p = P('~')
Expand Down Expand Up @@ -2508,7 +2509,8 @@ def _check_symlink_loop(self, *args, strict=True):
print(path.resolve(strict))

@unittest.skipIf(
is_emscripten, "umask is not implemented on Emscripten."
is_emscripten or is_wasi,
"umask is not implemented on Emscripten/WASI."
)
def test_open_mode(self):
old_mask = os.umask(0)
Expand All @@ -2534,7 +2536,8 @@ def test_resolve_root(self):
os.chdir(current_directory)

@unittest.skipIf(
is_emscripten, "umask is not implemented on Emscripten."
is_emscripten or is_wasi,
"umask is not implemented on Emscripten/WASI."
)
def test_touch_mode(self):
old_mask = os.umask(0)
Expand Down
5 changes: 4 additions & 1 deletion Lib/test/test_tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,10 @@ def test_stream_padding(self):

@unittest.skipUnless(sys.platform != "win32" and hasattr(os, "umask"),
"Missing umask implementation")
@unittest.skipIf(support.is_emscripten, "Emscripten's umask is a stub.")
@unittest.skipIf(
support.is_emscripten or support.is_wasi,
"Emscripten's/WASI's umask is a stub."
)
def test_file_mode(self):
# Test for issue #8464: Create files with correct
# permissions.
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_unicode_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _test_single(self, filename):
os.unlink(filename)
self.assertTrue(not os.path.exists(filename))
# and again with os.open.
f = os.open(filename, os.O_CREAT)
f = os.open(filename, os.O_CREAT | os.O_WRONLY)
os.close(f)
try:
self._do_single(filename)
Expand Down
6 changes: 5 additions & 1 deletion Tools/wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,11 @@ are:
yet. A future version of WASI may provide a limited ``set_permissions`` API.
- File locking (``fcntl``) is not available.
- ``os.pipe()``, ``os.mkfifo()``, and ``os.mknod()`` are not supported.
- ``process_time`` clock does not work.
- ``process_time`` does not work as expected because it's implemented using
wall clock.
- ``os.umask`` is a stub.
- ``sys.executable`` is empty.
- ``/dev/null`` / ``os.devnull`` may not be available.


# Detect WebAssembly builds
Expand Down
0