-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: refactor test-fs-buffer #11232
Conversation
test/parallel/test-fs-buffer.js
Outdated
assert.strictEqual( | ||
fromHexList, | ||
val, | ||
`${hexList[idx]} is hex value for ${fromHexList} and not ${val}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the more common wording would be something like
const valHex = Buffer.from(val).toString('hex');
const message = `expected ${valHex} as hex value for ${val}, ` +
`got ${hexList[idx]} (hex value for ${fromHexList})`
If I am reading this correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your wording is better. Will update...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this?:
`expected ${val}, got ${fromHexList} by hex decoding ${hexList[idx]}`
The thing I'm trying to convey is this: val
is the input. We put it in a file hex encoded. We read the file back in and got the hex-encoded value hexList[idx]
. When we hex decode that value, we got fromHexList
instead of val
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah your proposal works too, and it is more succinct :)
* Remove unneeded temp dir cleanup * Add check for error in `.close()` callback * Improve error reporting On that last bullet point, the previous version of the test reported errors like this: ``` AssertionError: [ '.empty-repl-history-file', '.node_repl_history', 'nodejsGH-1899-output.js', 'nodejsGH-892-request.js', 'a.js', 'a1.js', 'agen deepStrictEqual [ '.empty-repl-history-file', '.node_repl_history', 'nodejsGH-1899-output.js', 'nodejsGH-892-request.js', 'a.js', 'a1.js', 'agen ``` Now, they look like this: ``` AssertionError: 2a is hex value for * and not catch-stdout-error.js ```
* Remove unneeded temp dir cleanup * Add check for error in `.close()` callback * Improve error reporting On that last bullet point, the previous version of the test reported errors like this: ``` AssertionError: [ '.empty-repl-history-file', '.node_repl_history', 'nodejsGH-1899-output.js', 'nodejsGH-892-request.js', 'a.js', 'a1.js', 'agen deepStrictEqual [ '.empty-repl-history-file', '.node_repl_history', 'nodejsGH-1899-output.js', 'nodejsGH-892-request.js', 'a.js', 'a1.js', 'agen ``` Now, they look like this: ``` AssertionError: expected *, got ! by hex decoding 2a ``` PR-URL: nodejs#11232 Reviewed-By: James M Snell <[email protected]>
Landed in 05be623 |
* Remove unneeded temp dir cleanup * Add check for error in `.close()` callback * Improve error reporting On that last bullet point, the previous version of the test reported errors like this: ``` AssertionError: [ '.empty-repl-history-file', '.node_repl_history', 'GH-1899-output.js', 'GH-892-request.js', 'a.js', 'a1.js', 'agen deepStrictEqual [ '.empty-repl-history-file', '.node_repl_history', 'GH-1899-output.js', 'GH-892-request.js', 'a.js', 'a1.js', 'agen ``` Now, they look like this: ``` AssertionError: expected *, got ! by hex decoding 2a ``` PR-URL: #11232 Reviewed-By: James M Snell <[email protected]>
* Remove unneeded temp dir cleanup * Add check for error in `.close()` callback * Improve error reporting On that last bullet point, the previous version of the test reported errors like this: ``` AssertionError: [ '.empty-repl-history-file', '.node_repl_history', 'nodejsGH-1899-output.js', 'nodejsGH-892-request.js', 'a.js', 'a1.js', 'agen deepStrictEqual [ '.empty-repl-history-file', '.node_repl_history', 'nodejsGH-1899-output.js', 'nodejsGH-892-request.js', 'a.js', 'a1.js', 'agen ``` Now, they look like this: ``` AssertionError: expected *, got ! by hex decoding 2a ``` PR-URL: nodejs#11232 Reviewed-By: James M Snell <[email protected]>
* Remove unneeded temp dir cleanup * Add check for error in `.close()` callback * Improve error reporting On that last bullet point, the previous version of the test reported errors like this: ``` AssertionError: [ '.empty-repl-history-file', '.node_repl_history', 'nodejsGH-1899-output.js', 'nodejsGH-892-request.js', 'a.js', 'a1.js', 'agen deepStrictEqual [ '.empty-repl-history-file', '.node_repl_history', 'nodejsGH-1899-output.js', 'nodejsGH-892-request.js', 'a.js', 'a1.js', 'agen ``` Now, they look like this: ``` AssertionError: expected *, got ! by hex decoding 2a ``` PR-URL: nodejs#11232 Reviewed-By: James M Snell <[email protected]>
would need backport PRs to land in v4 or v6 |
.close()
callbackOn that last bullet point, the previous version of the test reported
errors like this:
Now, they look like this:
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test fs