Skip to content

Conversation

@jhwohlgemuth
Copy link
Contributor

  • make -j8 test
  • commit message follows commit guidelines
Affected core subsystem(s)
  • test
Description of change
  • Change equal to strictEqual (required addition of encoding="utf" parameter for readFileSync call)
  • Change var to const

@nodejs-github-botnodejs-github-bot added the test Issues and PRs related to the tests. label Dec 1, 2016
@mscdexmscdex added the fs Issues and PRs related to the fs subsystem / file system. label Dec 1, 2016
@imyllerimyller added the code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. label Dec 1, 2016
Copy link
Contributor

@princejwesleyprincejwesley left a comment

Choose a reason for hiding this comment

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

Commit message suggestion:
First line as test: refactor test-sync-fileread
and the description in subsequent line

Copy link
Contributor

Choose a reason for hiding this comment

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

Why the addition of 'utf8'? We should still test the case where the encoding is not provided. If anything, maybe add another assertion.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

According to the documentation:

If the encoding option is specified then this function returns a string. Otherwise it returns a buffer.

So, it seemed to me that the old test with just assert.equal was not actually doing much...although I could be wrong? In any case, I did not see much value in adding another test beyond what was added.

Perhaps I could add an assertion that compares Buffer content of a readFileSync call with no encoding? I am still new to the style and preferences of contributing to the Node.js project, but personally if I was to do such a thing, I would do so in a different PR in an effort to separate refactoring tests and adding tests.

Copy link
Member

Choose a reason for hiding this comment

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

TL;DR How about just change this line to this?:

assert.strictEqual(fs.readFileSync(fixture).toString(), 'xyz\n`);

The reasoning:

  • This line has the arguments reversed from the documentation. Let's switch them.

  • To address @cjihrig's comment, leave the fs.readFileSync() call as it was so that we're not altering the code path (in readFileSync()) that is being tested. Instead, apply toString() to the result so we can compare it to a string.

@Trott
Copy link
Member

Aside: If you (or someone else) wants a good second PR after this lands: Merge this and test-fs-read-file-sync.js into a single file named test-fs-readfilesync.js.

Copy link
Member

@TrottTrott left a comment

Choose a reason for hiding this comment

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

Ping! @jhwohlgemuth Any chance you can address the make the change requested in https://github.com/nodejs/node/pull/9941/files#r92760787?

@jhwohlgemuth
Copy link
ContributorAuthor

@Trott Updated with requested changes.

@Trott
Copy link
Member

@italoacasas
Copy link

Landed 5c85ae6

targos pushed a commit that referenced this pull request Dec 26, 2016
change equal to strictEqual and var to const PR-URL: #9941 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]>
@MylesBorinsMylesBorins mentioned this pull request Dec 27, 2016
targos pushed a commit that referenced this pull request Dec 28, 2016
change equal to strictEqual and var to const PR-URL: #9941 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]>
@evanlucasevanlucas mentioned this pull request Jan 3, 2017
evanlucas pushed a commit that referenced this pull request Jan 3, 2017
change equal to strictEqual and var to const PR-URL: #9941 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]>
evanlucas pushed a commit that referenced this pull request Jan 4, 2017
change equal to strictEqual and var to const PR-URL: #9941 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]>
targos pushed a commit that referenced this pull request Jan 23, 2017
change equal to strictEqual and var to const PR-URL: #9941 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jan 24, 2017
change equal to strictEqual and var to const PR-URL: #9941 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]>
@MylesBorinsMylesBorins mentioned this pull request Jan 24, 2017
MylesBorins pushed a commit that referenced this pull request Feb 1, 2017
change equal to strictEqual and var to const PR-URL: #9941 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-and-learnIssues related to the Code-and-Learn events and PRs submitted during the events.fsIssues and PRs related to the fs subsystem / file system.testIssues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

11 participants

@jhwohlgemuth@Trott@italoacasas@lpinca@princejwesley@cjihrig@mscdex@MylesBorins@imyller@targos@nodejs-github-bot