Move the child process code into a fixture and split the test
so that it can be run in parallel and it's easier to identify
where the failure is coming from. Also use the
spawnSyncAndExitWithoutError() utility so that the test shows
complete information on failure.
Instead of marking all the wasi tests as flaky, only mark the
wasi-poll one which is flaking in the CI now.
PR-URL: https://github.com/nodejs/node/pull/51836
Refs: https://github.com/nodejs/node/issues/51822
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
- update uvwasi to 0.0.20
- adjust tests to reflect udpated behaviour from
https://github.com/nodejs/uvwasi/pull/224 included
in uvwasi 0.0.20
Signed-off-by: Michael Dawson <midawson@redhat.com>
PR-URL: https://github.com/nodejs/node/pull/51355
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
ibmi now reports os400 instead of aix
- update platform check in poll to allow for os400
- update wasi-sdk level to 20
- document the level of wasi-sdk used to compile the tests
- remove platform check in readdir test as it does not seem to be
needed with wasi-sdk version 20
- comment out tests for some clocks which are no longer available when
compiling with wasi-sdk level 20. These may be added back after
https://github.com/WebAssembly/wasi-libc/issues/266 is resolved.
Signed-off-by: Michael Dawson <midawson@redhat.com>
PR-URL: https://github.com/nodejs/node/pull/49953
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
We had a few code snippets that were using a non-descriptive tag (e.g.
`console` or `text`), whereas the actual language it's using describes
it better, and improves the syntax highlighting. This commit also
removes non-necessary leading chars (e.g. `$`, `>`, or `%`) to make it
easier for readers to copy and paste to try the command themselves.
PR-URL: https://github.com/nodejs/node/pull/48082
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Refs: https://github.com/nodejs/node/issues/46923
Signed-off-by: Michael Dawson <mdawson@devrus.com>
PR-URL: https://github.com/nodejs/node/pull/47390
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
- remove default for version
- updates tests to specify version
- add test for when version is not specified
Signed-off-by: Michael Dawson <mdawson@devrus.com>
PR-URL: https://github.com/nodejs/node/pull/47391
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
- no longer require flag to enable experimental wasi feature
- wasi is still documented as experimental
Signed-off-by: Michael Dawson <mdawson@devrus.com>
PR-URL: https://github.com/nodejs/node/pull/47286
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Refs: https://github.com/nodejs/uvwasi/pull/185
Add stub for sock_accept so that we have stubs
for all of the sock methods in wasi_snapshot_preview1.
Its a bit awkward as the method was added after the
initial definitial of wasi_snapshot-preview1 but I
think it should be semver minor at most to add
the method.
Depends on https://github.com/nodejs/uvwasi/pull/185
being landed in uvwasi first and an updated version
of uvwasi that includes that being pulled into
Node.js
Signed-off-by: Michael Dawson <mdawson@devrus.com>
PR-URL: https://github.com/nodejs/node/pull/46434
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Refs: https://github.com/nodejs/node/issues/46254
- add version to options when creating WASI object
- add convenience function to return importObject
Signed-off-by: Michael Dawson <mdawson@devrus.com>
PR-URL: https://github.com/nodejs/node/pull/46469
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Only activated on some subfolders to minimize the diff, ideally this
rule would be applied gradually to the entire codebase in follow-up
commits.
PR-URL: https://github.com/nodejs/node/pull/45468
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/40156
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
It is possible on Windows to configure Git to checkout line-endings
"as-is", which for Node.js means Unix-style.
This change makes the tests that rely on line endings pass in that case.
PR-URL: https://github.com/nodejs/node/pull/40002
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
The WASI link test attempts to create a link in the temporary directory
to a file in the fixtures directory and can fail if those directories
are on different devices. Update the test so that both the source and
target of the link reside on the same device.
PR-URL: https://github.com/nodejs/node/pull/39485
Fixes: https://github.com/nodejs/node/issues/39484
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
The `wasi` lib module's `initialize()` method is missing a validator.
PR-URL: https://github.com/nodejs/node/pull/39070
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Make changes so that tests will pass when the comma-dangle settings
applied to the rest of the code base are also applied to tests.
PR-URL: https://github.com/nodejs/node/pull/37930
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is>
Starting with the V8 8.8 update, this test has been regularly
crashing with an out of memory error on 32-bit Windows. The issue
has been narrowed down to a function not being bound. This seems
like a V8 bug, but at least it seems that we can work around it.
Fixes: https://github.com/nodejs/node/issues/37374
PR-URL: https://github.com/nodejs/node/pull/37615
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
After the V8 8.5 update, the WASI APIs no longer require the
use of --experimental-wasm-bigint. This commit removes its use.
PR-URL: https://github.com/nodejs/node/pull/35415
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
This makes sure that all async functions finish as expected.
PR-URL: https://github.com/nodejs/node/pull/34363
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit adds a WASI test to cover the following functions:
- __wasi_fd_filestat_set_size()
- __wasi_fd_tell()
PR-URL: https://github.com/nodejs/node/pull/31617
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit adds stdin, stderr, and stdout options to WASI, which
allow the stdio streams to be configured.
PR-URL: https://github.com/nodejs/node/pull/33544
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit refactors and enables the poll_oneoff() WASI test.
The refactor includes testing additional cases, as well as some
platform specific checks.
PR-URL: https://github.com/nodejs/node/pull/33521
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Be careful when emitting the 'beforeExit' event. It's not allowed to
call into the runtime when a termination exception is pending.
Fixes: https://github.com/nodejs/node/issues/33377
PR-URL: https://github.com/nodejs/node/pull/33386
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Instances coming from different VM contexts don't pass `instanceof`
type checks because each context has its own copy of the built-in
globals.
After review of the relevant code it seems like it should be safe to
relax the type check and that is what this commit does: `wasi.start()`
now accepts any input that walks and quacks like a WebAssembly.Instance
or WebAssembly.Memory instance.
Fixes: https://github.com/nodejs/node/issues/33415
PR-URL: https://github.com/nodejs/node/pull/33431
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
_start() and _initialize() shouldn't be called from the same
function, as they have different behavior. Furthermore, Node
should throw if both are provided. This commit updates the
implementation, docs, and tests accordingly.
PR-URL: https://github.com/nodejs/node/pull/33073
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Upstream WASI has renamed __wasi_unstable_reactor_start() to
_initialize(). This commit updates Node's WASI implementation to
reflect that change.
PR-URL: https://github.com/nodejs/node/pull/33073
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
The API clock_getres with attribute API CLOCK_THREAD_CPUTIME_ID
is not supported on IBM i PASE.
PR-URL: https://github.com/nodejs/node/pull/32459
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit adds a test to verify that exceptions thrown from a
WASI application are properly caught and rethrown. This also
gets the code coverage in lib/wasi.js back to 100%.
PR-URL: https://github.com/nodejs/node/pull/32157
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit adds a WASI option allowing the __wasi_proc_exit()
function to return an exit code instead of forcefully terminating
the process.
PR-URL: https://github.com/nodejs/node/pull/32101
Fixes: https://github.com/nodejs/node/issues/32093
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This test provides missing coverage for __wasi_args_get() and
__wasi_args_sizes_get(), which translate to argc and argv in
WASI applications.
PR-URL: https://github.com/nodejs/node/pull/31426
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit improved the stat test a bit by verifying that
S_ISDIR() works properly. It also adds missing coverage for
__wasi_path_remove_directory().
PR-URL: https://github.com/nodejs/node/pull/31413
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This test provides missing coverage for __wasi_path_symlink()
and __wasi_path_readlink().
PR-URL: https://github.com/nodejs/node/pull/31403
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit updates the uvwasi dependency to version 0.0.4. The
most notable change is a refactor of the way paths are resolved.
All paths, including symlinks, are now resolved in terms of
sandboxed paths instead of leaking host system paths.
PR-URL: https://github.com/nodejs/node/pull/31363
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Prior to this commit, if uvwasi_init() failed in any way, Node
would abort due to a failed CHECK_EQ(). This commit changes
that behavior to a thrown exception.
PR-URL: https://github.com/nodejs/node/pull/31076
Fixes: https://github.com/nodejs/node/issues/30878
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit covers the last remaining uncovered code in
lib/wasi.js.
PR-URL: https://github.com/nodejs/node/pull/31039
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>