vfs: add minimal node:vfs subsystem#63115
Conversation
|
Review requested:
|
The docs in this PR claim that you can call |
30f5755 to
779fc37
Compare
Fixed, good spot. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #63115 +/- ##
==========================================
- Coverage 91.94% 90.24% -1.70%
==========================================
Files 362 726 +364
Lines 155999 231715 +75716
Branches 24057 43706 +19649
==========================================
+ Hits 143429 209113 +65684
- Misses 12295 14388 +2093
- Partials 275 8214 +7939
🚀 New features to boost your workflow:
|
|
Can you add a test for #63158? |
| let data = ''; | ||
|
|
||
| stream.on('open', common.mustCall((fd) => { | ||
| assert.ok((fd & 0x40000000) !== 0); |
There was a problem hiding this comment.
| assert.ok((fd & 0x40000000) !== 0); | |
| assert.notStrictEqual(fd & 0x40000000, 0); |
| ws.on('error', common.mustCall((err) => { | ||
| assert.ok(err); | ||
| })); |
There was a problem hiding this comment.
| ws.on('error', common.mustCall((err) => { | |
| assert.ok(err); | |
| })); | |
| ws.on('error', common.expectsError()); |
| ws.on('error', common.mustCall((err) => { | ||
| assert.ok(err); | ||
| })); |
There was a problem hiding this comment.
| ws.on('error', common.mustCall((err) => { | |
| assert.ok(err); | |
| })); | |
| ws.on('error', common.expectsError()); |
| const fd = myVfs.openSync('/cl.txt'); | ||
| const rs = myVfs.createReadStream('/cl.txt', { fd, autoClose: true }); | ||
| myVfs.closeSync(fd); | ||
| rs.on('error', common.mustCall()); |
There was a problem hiding this comment.
| rs.on('error', common.mustCall()); | |
| rs.on('error', common.expectsError()); |
| rs.on('error', common.mustCall((err) => { | ||
| assert.strictEqual(err.code, 'EBADF'); | ||
| })); |
There was a problem hiding this comment.
| rs.on('error', common.mustCall((err) => { | |
| assert.strictEqual(err.code, 'EBADF'); | |
| })); | |
| rs.on('error', common.expectsError({ | |
| code: 'EBADF', | |
| })); |
| stream.on('error', common.mustCall((err) => { | ||
| assert.strictEqual(err.code, 'ENOENT'); | ||
| })); |
There was a problem hiding this comment.
| stream.on('error', common.mustCall((err) => { | |
| assert.strictEqual(err.code, 'ENOENT'); | |
| })); | |
| stream.on('error', common.expectsError({ | |
| code: 'ENOENT', | |
| })); |
Co-authored-by: Antoine du Hamel <[email protected]> Co-authored-by: Matteo Collina <[email protected]>
* test-vfs-stream-errors: drop the unused `assert` import. * test-vfs-streams: capitalize a lowercase comment to satisfy capitalized-comments. Signed-off-by: Matteo Collina <[email protected]>
Co-authored-by: Antoine du Hamel <[email protected]>
spawnSyncAndAssert handles the expected stderr/status, so the top-level `assert` is no longer referenced. Signed-off-by: Matteo Collina <[email protected]>
Signed-off-by: Matteo Collina <[email protected]>
Qard
left a comment
There was a problem hiding this comment.
LGTM. Some minor improvements which could be made, but nothing which needs to block landing. 🙂
The currentPath segment used for symlink resolution and for the #ensurePopulated call below was being computed twice in the loop body. Compute it once at the top of the iteration and reuse it in both branches. Signed-off-by: Matteo Collina <[email protected]>
Adds an experimental
node:vfsbuiltin (gated behind--experimental-vfs) withVirtualFileSystem,VirtualProvider,MemoryProvider, andRealFSProvider. No integration withnode:fs, the module loader, or SEA those are intended to land in follow-up PRs.Extracted from: #61478
Approximate line counts: code ~4k / docs ~1k / tests ~5k — total ~10k lines, with tests being the largest share.