Repository navigation
test: add file system test suite - #6555
Conversation
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a reusable layered filesystem conformance suite covering paths, temporary resources, streams, handles, mutations, and adapter capabilities. Node filesystem tests now consume the shared suite and retain focused fixture and truncation-cursor checks. ChangesFilesystem adapter conformance
Estimated code review effort: 4 (Complex) | ~45 minutes Suggested labels: 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/platform-node-shared/test/NodeFileSystem.test.ts (1)
13-19: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winWrap these Effect test bodies with
Effect.fnUntraced.Each callback only returns
Effect.gen; passEffect.fnUntraced(function*() { ... })directly toit.effectinstead. As per coding guidelines, “In Effect TypeScript code, preferEffect.fnUntracedover functions that only returnEffect.gen.”Proposed pattern
- it.effect("...", () => - Effect.gen(function*() { + it.effect("...", Effect.fnUntraced(function*() { // assertions - })) + }))Also applies to: 21-33, 35-46
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/platform-node-shared/test/NodeFileSystem.test.ts` around lines 13 - 19, Update the affected it.effect callbacks, including the test at “should read a pre-existing host file when the fixture exists” and the tests at the referenced ranges, to pass Effect.fnUntraced(function*() { ... }) directly instead of an arrow function returning Effect.gen. Preserve each generator’s existing filesystem operations and assertions.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/platform-node-shared/test/NodeFileSystem.test.ts`:
- Around line 13-19: Update the affected it.effect callbacks, including the test
at “should read a pre-existing host file when the fixture exists” and the tests
at the referenced ranges, to pass Effect.fnUntraced(function*() { ... })
directly instead of an arrow function returning Effect.gen. Preserve each
generator’s existing filesystem operations and assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 10852250-fd39-471d-a7aa-7a8663c896cc
📒 Files selected for processing (2)
packages/effect/test/FileSystemTest.tspackages/platform-node-shared/test/NodeFileSystem.test.ts
| assert.strictEqual(yield* fs.readFileString(renameDestination), "renamed") | ||
| })) | ||
|
|
||
| // TODO: Define whether overwrite: false succeeds without changing an existing destination or fails with AlreadyExists. |
There was a problem hiding this comment.
Define whether overwrite: false succeeds without changing an existing destination or fails with AlreadyExists.
What remains undecided:
- Successful no-op <- copying to an existing destination with overwrite: false succeeds but leaves it untouched. This suits idempotent setup flows.
- AlreadyExists failure <- it reports that the requested copy did not happen. This suits callers that need to distinguish "copied" from "skipped"
There was a problem hiding this comment.
This remains a public-contract question. Node skips an existing destination with overwrite: false; Deno reports AlreadyExists, with its error mapping addressed in #7086. The suite still accepts either outcome and checks that the destination contents are preserved. I updated the TODO with that concrete difference. Leaving this open for a decision on whether success/failure must agree across adapters.
| assertSystemError(error, { tag: "NotFound", method: "open", pathOrDescriptor: missing }) | ||
| })) | ||
|
|
||
| // TODO: Add a deterministic synchronization point before covering stream and sink finalization after interruption. |
There was a problem hiding this comment.
Add a deterministic synchronization point before covering stream and sink finalization after interruption.
Add a test-only synchronization hook that blocks after the derived handle is acquired? Then interrupt the stream or sink and assert that its handle finalizer runs.
There was a problem hiding this comment.
The remaining work is a test addition, not a public synchronization API. The existing trackedFs.open wrapper can signal acquisition through a Deferred; then the test can interrupt a blocked stream or sink and assert finalization. I made the TODO specific. Leaving this open because interruption coverage has not been implemented in this comment-only cleanup.
| assertSystemError(error, { method: "realPath", pathOrDescriptor: first }) | ||
| })) | ||
|
|
||
| // TODO: Add positive chmod and chown conformance in a POSIX-only metadata capability suite. |
There was a problem hiding this comment.
Add positive chmod and chown conformance in a POSIX-only metadata capability suite.
should an in memory adapter intentionally omit identity/permission modeling?
There was a problem hiding this comment.
Partially answered by #7943: Deno now uses successful chmod to test that writing an existing file preserves its mode. The MemoryFileSystem proposal in #6573 stores permissions and ownership without enforcing a virtual identity. The remaining TODO is positive chmod/chown conformance gated by adapter/host support and ownership privileges. I removed the empty test placeholder. Leaving the coverage work open.
| } | ||
| })) | ||
|
|
||
| // TODO: Define whether preserveTimestamps guarantees only mtime or both atime and mtime. Node preserves mtime but resets atime. |
There was a problem hiding this comment.
Define whether preserveTimestamps guarantees only mtime or both atime and mtime.
Node preserves mtime but resets atime, so baseline conformance currently checks only mtime
There was a problem hiding this comment.
The shared test continues to assert mtime preservation. I narrowed the TODO to the unanswered part: whether preserveTimestamps must also preserve atime. The previous blanket statement about Node resetting atime is removed; this cleanup does not establish a stronger timestamp guarantee. Leaving the contract question open.
| assert.isTrue(matches[0].endsWith("src/index.ts")) | ||
| })) | ||
|
|
||
| // TODO: Add deterministic watcher-registration and subscription-control hooks before specifying event ordering, |
There was a problem hiding this comment.
Add deterministic watcher-registration and subscription-control hooks before specifying event ordering, normalized paths, or watcher cleanup
There was a problem hiding this comment.
Partially addressed: the Node-specific startWatch helper already waits for a sentinel event before testing changes. I split the TODO into adapter readiness/cleanup coverage and a separate portable event-path decision. Node emits filenames while Deno forwards native event paths; exact native event ordering should not be a prerequisite for cleanup tests. Leaving the remaining work open.
b140b7e to
cf04641
Compare
cf04641 to
f1758ca
Compare
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
f1758ca to
a02c21d
Compare
a02c21d to
206ff16
Compare
|
Since Deno was added in the mean time I've added this too with the suite and even managed to find a bug with the open flag and error normalization |
206ff16 to
9ea3814
Compare
|
@tim-smart since its been a minute on this PR I just wanted to give you a gentle judge to see if you still want to review it. I understand reviewing tests isn't much fun but there are some open questions i've added comments to which could be points for discussion or further development. That said, if you think the |
2492ba9 to
516ae44
Compare
516ae44 to
47ffc73
Compare
47ffc73 to
b45bf32
Compare
b45bf32 to
eb99f83
Compare
eb99f83 to
25417f2
Compare
|
I revisited the open questions against the recent Deno work and updated the inline threads. Seek, truncate-cursor behavior, and missing-watch errors are covered now. Working-directory and permission semantics stay adapter-specific. The two contract questions I’d appreciate input on are:
My preference is to keep the current minimum guarantees for this PR and handle stronger guarantees separately. I’ve made the remaining test and error-normalization TODOs concrete so those can progress independently. |
Co-authored-by: Lloyd Richards <[email protected]>
25417f2 to
55b66ab
Compare
Type
Description
Extends the shared FileSystem conformance suite (
testLayerinpackages/effect/test/FileSystem.test-utils.ts) with the cross-adapter coverage from this PR thatmaindid not already have. Node and Deno both run it through their existing test files.This branch was rebuilt on current
main. Since this PR was opened,maingained a sharedtestLayerthat already covers the write flags, cursor and truncate behavior, seek results andoverwrite: false, so the newFileSystemTest.tsfile was dropped. The remaining additions cover:makeDirectory,remove,copyandrenamesemantics, including trailing separators and missing sourcesopenflag matrix (creation, exclusivity, read and write access)NotFoundnormalization across path operations, andBadResourcewhen a file is used as a directoryutimesandpreserveTimestamps(mtime only),globexcludesWhere adapters currently disagree (
copywithoverwrite: false,globpath form, atime underpreserveTimestamps), the suite asserts only the behavior both share. Aligning them would be a runtime change and is left for a separate PR.Test-only, so no changeset.
Closes EFF-2673
Related