node/test
Joyee Cheung 813713f211
fs: throw errors from sync branches instead of separate implementations
Previously to throw errors from C++ land, sync versions of the fs
were created by copying C++ code from the original implementation
and moving JS code to a separate file. This can lead to several
problems:

1. By moving code to a new file for the sake of moving, it would
  be harder to use git blame to trace changes and harder to backport
  changes to older branches.
2. Scattering the async and sync versions of fs methods in
  different files makes it harder to keep them in sync and
  share code in the prologues and epilogues.
3. Having two copies of code doing almost the same thing results
  in duplication and can be prone to out-of-sync problems when the
  prologue and epilogue get updated.
4. There is a minor cost to startup in adding an additional file.
  This can add up even with the help of snapshots.

This patch moves the JS code back to lib/fs.js to stop 1, 2 & 4
and introduces C++ helpers SyncCallAndThrowIf() and
SyncCallAndThrowOnError() so that the original implementations
can be easily tweaked to allow throwing from C++ and stop 3.

PR-URL: https://github.com/nodejs/node/pull/49913
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2023-09-30 01:17:00 +00:00
..
abort test: disambiguate AIX and IBM i 2023-09-29 18:26:27 +00:00
addons test: use tmpdir.resolve() 2023-08-21 16:41:53 +00:00
async-hooks test: use tmpdir.resolve() 2023-08-21 16:41:53 +00:00
benchmark url: drop ICU requirement for parsing hostnames 2023-04-05 09:05:29 -07:00
cctest test: fix compiler warning in NodeCryptoEnv 2023-08-24 16:25:09 +00:00
common test: disambiguate AIX and IBM i 2023-09-29 18:26:27 +00:00
doctool doc: rename possibly confusing variable and CSS class 2023-09-08 17:03:57 +02:00
embedding test: fix argument computation in embedtest 2023-09-18 00:06:20 +02:00
es-module esm: fix cache collision on JSON files using file: URL 2023-09-29 08:46:32 +00:00
fixtures crypto: return clear errors when loading invalid PFX data 2023-09-29 10:56:33 +00:00
fuzzers
internet test: use tmpdir.resolve() 2023-08-21 16:41:53 +00:00
js-native-api node-api: enable uncaught exceptions policy by default 2023-09-25 04:23:58 +00:00
known_issues test: disambiguate AIX and IBM i 2023-09-29 18:26:27 +00:00
message errors: improve performance of instantiation 2023-09-28 09:57:38 +00:00
node-api node-api: enable uncaught exceptions policy by default 2023-09-25 04:23:58 +00:00
overlapped-checker
parallel fs: throw errors from sync branches instead of separate implementations 2023-09-30 01:17:00 +00:00
pseudo-tty test: migrate a pseudo_tty test to use assertSnapshot 2023-05-04 08:34:23 +00:00
pummel test: use setImmediate() in test-heapdump-shadowrealm.js 2023-09-11 15:56:01 +00:00
report test: use tmpdir.resolve() 2023-08-21 16:41:53 +00:00
sequential test: deflake test-perf-hooks.js 2023-09-29 18:14:01 +02:00
testpy
tick-processor test: use tmpdir.resolve() 2023-08-21 16:41:53 +00:00
tools build: replace js2c.py with js2c.cc 2023-05-24 13:33:01 +02:00
v8-updates
wasi wasi: updates required for latest uvwasi version 2023-09-29 15:16:51 -04:00
wpt lib: allow byob reader for 'blob.stream()' 2023-09-22 06:16:46 +00:00
.eslintrc.yaml test: remove unnecessary noop function args to mustNotCall() 2023-06-24 16:16:07 +02:00
README.md
root.status test: mark test_cannot_run_js as flaky 2023-05-27 23:40:05 +00:00

Node.js Core Tests

This directory contains code and data used to test the Node.js implementation.

For a detailed guide on how to write tests in this directory, see the guide on writing tests.

On how to run tests in this directory, see the contributing guide.

For the tests to run on Windows, be sure to clone Node.js source code with the autocrlf git config flag set to true.

Test Directories

Directory Runs on CI Purpose
abort Yes Tests that use --abort-on-uncaught-exception and other situations where we want to test something but avoid generating a core file.
addons Yes Tests for addon functionality along with some tests that require an addon.
async-hooks Yes Tests for async_hooks functionality.
benchmark Yes Test minimal functionality of benchmarks.
cctest Yes C++ tests that are run as part of the build process.
code-cache No Tests for a Node.js binary compiled with V8 code cache.
common Common modules shared among many tests. Documentation
doctool Yes Tests for the documentation generator.
es-module Yes Test ESM module loading.
fixtures Test fixtures used in various tests throughout the test suite.
internet No Tests that make real outbound network connections. Tests for networking related modules may also be present in other directories, but those tests do not make outbound connections.
js-native-api Yes Tests for Node.js-agnostic Node-API functionality.
known_issues Yes Tests reproducing known issues within the system. All tests inside of this directory are expected to fail. If a test doesn't fail on certain platforms, those should be skipped via known_issues.status.
message Yes Tests for messages that are output for various conditions (console.log, error messages etc.)
node-api Yes Tests for Node.js-specific Node-API functionality.
parallel Yes Various tests that are able to be run in parallel.
pseudo-tty Yes Tests that require stdin/stdout/stderr to be a TTY.
pummel No Various tests for various modules / system functionality operating under load.
sequential Yes Various tests that must not run in parallel.
testpy Test configuration utility used by various test suites.
tick-processor No Tests for the V8 tick processor integration. The tests are for the logic in lib/internal/v8_prof_processor.js and lib/internal/v8_prof_polyfill.js. The tests confirm that the profile processor packages the correct set of scripts from V8 and introduces the correct platform specific logic.
v8-updates No Tests for V8 performance integration.