-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
#3354: Annotate when exceptions are caught but ignored #3356
Changes from 3 commits
8d6a1eb
68b3596
eb034dd
9be70b4
62be918
9daaa5c
792b340
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,8 +30,8 @@ function getOptions() { | |
: process.argv[process.argv.indexOf('--opts') + 1]; | ||
|
||
try { | ||
const opts = fs | ||
.readFileSync(optsPath, 'utf8') | ||
// prettier-ignore | ||
const opts = fs.readFileSync(optsPath, 'utf8') | ||
.replace(/\\\s/g, '%20') | ||
.split(/\s/) | ||
.filter(Boolean) | ||
|
@@ -40,8 +40,8 @@ function getOptions() { | |
process.argv = process.argv | ||
.slice(0, 2) | ||
.concat(opts.concat(process.argv.slice(2))); | ||
} catch (err) { | ||
// ignore | ||
} catch (ignore) { | ||
// NOTE: should console.error() and throw the error | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What did you mean by this comment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly what it says. Believe it's a shortcoming of existing code. If anything goes wrong parsing the "mocha.opts" file or splicing its pieces/parts back into the cmdline arguments, the error is silently discarded. This just seems wrong, so I made a note; figured it should at least be discussed (and hopefully fixed in different issue). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @plroebuck I got it. Thank you for the explanation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You concur about throw? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And if an error occurs in the above, should that environment variable be set (L47)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think we should be emitting a warning here, at minimum--unless there's some Git or issue history that makes me think otherwise. That env var should be set anyway, because it's only used to check whether or not But that's another issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. |
||
} | ||
|
||
process.env.LOADED_MOCHA_OPTS = true; | ||
|
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.
Why did you ignore prettier 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.
Because the first function call is to
fs.readFileSync()
; there is no good reason to split the module from the function call -- not to mention it looks stupid. The rest of the chain processes its result via various FP methods (indented as expected for chained methods).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 also like that no splitting the module and function call.
However, I believe that we should minimalize inline ignore because we decided to follow Prettier.
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.
If the formatting of this code is more important than its readability, then I'll take it out.
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.
please take it out, thanks