-
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: improve the code in test-fs-null-bytes #10521
Conversation
}); | ||
|
||
if (sync) | ||
assert.throws(function() { | ||
console.error(sync.name, argsSync); | ||
assert.throws(common.mustCall(() => { |
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.
Nit: I think that wrapping this with common.mustCall()
is useless as it would only be wrapped when sync is truthy.
var expected = /Path must be a string without null bytes/; | ||
var argsSync = Array.prototype.slice.call(arguments, 2); | ||
var argsAsync = argsSync.concat(function(er) { | ||
const expected = /Path must be a string without null bytes/; |
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.
Nit: can we use /^Error: Path must be a string without null bytes$/
?
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.
@lpinca , removed the unnecessary common.mustCall
, but this one is asserting against the error message and the error message is exactly that one: https://github.com/nodejs/node/blob/master/lib/fs.js#L118
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.
Yes, other tests use the full message with boundaries, ^$
, and I would like to be consistent here.
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.
@lpinca this test is using that variable twice to validate the error, one of these is an assert.throws
if I set the boundaries that one will fail, I could use 2 different vars to test the error... but... not sure if worth it?
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.
@edsadr you are right, I missed that other assertion. I think it's fine to keep it as is then. Sorry for the confusion.
* use const instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions * remove console.error
Landed in 6830849. |
* use const instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions * remove console.error PR-URL: #10521 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
* use const instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions * remove console.error PR-URL: nodejs#10521 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
* use const instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions * remove console.error PR-URL: nodejs#10521 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
* use const instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions * remove console.error PR-URL: nodejs#10521 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
* use const instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions * remove console.error PR-URL: nodejs#10521 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
* use const instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions * remove console.error PR-URL: #10521 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
* use const instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions * remove console.error PR-URL: #10521 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test
Description of change