Skip to content
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

test: add fs/promises filehandle sync() and datasync() tests. #20530

Closed

Conversation

shisama
Copy link
Contributor

@shisama shisama commented May 5, 2018

To increase test coverage for fs/promises,
added tests for filehandle.sync and filehandle.datasync.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label May 5, 2018
await handle.datasync();
await handle.sync();
const buf = Buffer.from('hello world');
await write(handle, buf);
Copy link
Member

@ChALkeR ChALkeR May 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handle.write(buf)?
Same results and coverage, also see #20559.

await handle.sync();
const buf = Buffer.from('hello world');
await write(handle, buf);
const ret = await read(handle, Buffer.alloc(11), 0, 11, 0);
Copy link
Member

@ChALkeR ChALkeR May 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read(handlehandle.read(? See the comment above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChALkeR Fixed them. Thanks.

@ChALkeR ChALkeR added experimental Issues and PRs related to experimental features. fs Issues and PRs related to the fs subsystem / file system. labels May 8, 2018
@shisama shisama force-pushed the test-fs-promises-file-handle-sync branch from 1ff5b56 to e8f8408 Compare May 9, 2018 01:50
@ChALkeR
Copy link
Member

ChALkeR commented May 20, 2018

/cc @Trott

@BridgeAR
Copy link
Member

@shisama shisama force-pushed the test-fs-promises-file-handle-sync branch from 5784c2d to 2b54d4a Compare June 5, 2018 11:27
@shisama
Copy link
Contributor Author

shisama commented Jun 5, 2018

This is rebased on 0300f7c. make -j4 test is passed.

@apapirovski
Copy link
Member

@nodejs/fs please give this a look and a review, if possible. It's been over a month.

Copy link
Member

@joyeecheung joyeecheung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem to actually test that fsync and fdatasync calls are effective, but I am not quite sure how to write tests for them with our APIs either, so LGTM as long as the code paths are covered.

assert.deepStrictEqual(ret.buffer, buf);
}

validateSync().then(common.mustCall());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

common.mustCall() here seems unnecessary. If anything, common.crashOnUnhandledRejection() above gives a better hint about why it fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joyeecheung Thanks. Removed common.mustCall().

Masashi Hirano added 4 commits June 10, 2018 16:37
To increase test coverage for fs/promises,
added tests for filehandle.sync and filehandle.datasync.
Replacing fs/promises methods read and write with  fs/promises
filehandle methods.
Fix module loading because fs/promises was moved to fs.promises
@shisama shisama force-pushed the test-fs-promises-file-handle-sync branch from 2b54d4a to d462d2c Compare June 10, 2018 08:50
@apapirovski
Copy link
Member

@apapirovski apapirovski added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 25, 2018
@shisama
Copy link
Contributor Author

shisama commented Jun 30, 2018

CI failure is not related to this. It happens in parallel/test-timers-same-timeout-wrong-list-deleted.

@hiroppy
Copy link
Member

hiroppy commented Jun 30, 2018

CI: https://ci.nodejs.org/job/node-test-pull-request/15690/

@shisama
Copy link
Contributor Author

shisama commented Jul 7, 2018

I think CI failure node-test-commit-windows-fanned is not related to this.

@targos
Copy link
Member

targos commented Jul 15, 2018

targos pushed a commit to targos/node that referenced this pull request Jul 15, 2018
To increase test coverage for fs.promises,
added tests for filehandle.sync and filehandle.datasync.

PR-URL: nodejs#20530
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@targos
Copy link
Member

targos commented Jul 15, 2018

Landed in 71ca076. Thanks for the contribution @shisama.

@targos targos closed this Jul 15, 2018
@targos targos removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jul 15, 2018
targos pushed a commit that referenced this pull request Jul 15, 2018
To increase test coverage for fs.promises,
added tests for filehandle.sync and filehandle.datasync.

PR-URL: #20530
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experimental Issues and PRs related to experimental features. fs Issues and PRs related to the fs subsystem / file system. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants