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

3363: Throw error if unable to parse Mocha options file #3381

Closed
wants to merge 4 commits into from

Conversation

plroebuck
Copy link
Contributor

Description of the Change

Code now throws an error for any problems loading the Mocha options file (except nonexistent default "test/mocha.opts").

Builds off of previous discussions and work done in PR #2716 and PR #3352 .

Why should this be in core?

Silently ignoring problems loading this file is just wrong.

Benefits

Users will now be told if the file failed to load.

Possible Drawbacks

Users with invalid Mocha options files (or permissions problems, etc.) will need to correct the problem.

Applicable issues

Fixes #3363
Fixes #2576
(server-major) [since Mocha could throw an error when it didn't previously]

Code now throws an error for any problems (except nonexistent default "test/mocha.opts"). Includes
tests.

Fixes mochajs#3363 Fixes mochajs#2576
@plroebuck
Copy link
Contributor Author

Previous discussion occurred in PR #3376.

@outsideris outsideris added area: usability concerning user experience or interface semver-major implementation requires increase of "major" version number; "breaking changes" labels May 13, 2018
@plroebuck
Copy link
Contributor Author

Please add @rossgardt as contributor to this PR if it is merged.
It incorporates his additions from PR #3352.

@boneskull
Copy link
Contributor

@plroebuck There's no way for me to do that, AFAIK. You'll have to cherry-pick or rebase any of @rossgardt's changesets into this branch

@plroebuck
Copy link
Contributor Author

@boneskull, you have any issues with the PR? Approve?

@benedikt-roth
Copy link

benedikt-roth commented May 17, 2018 via email

@benedikt-roth
Copy link

What is the status of this PR? @plroebuck @boneskull

@plroebuck plroebuck added this to the v6.0.0 milestone Nov 2, 2018
Minor correction needed attempting to merge newer modifications to this file with this fix.
prettier, I doth loathe you...
@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 90.621% when pulling fcb6fb4 on plroebuck:issue/3363 into 9f02180 on mochajs:master.

@boneskull
Copy link
Contributor

the good news is that this PR looks good.

the bad news is that #3556 deprecates getOptions entirely (it's public, so I'm gonna leave it for now, but Mocha no longer uses it) and also adds this functionality. see https://github.com/mochajs/mocha/blob/yargs/lib/cli/options.js#L104

@plroebuck
Copy link
Contributor Author

How could you possibly have deprecated it completely? It would still at minimum contain Node-related cmdline options, as they would not seem to be appropriate content for ".mocharc.yml". Even if deprecated, your code doesn't incorporate the PR's changes.

@boneskull
Copy link
Contributor

mocha.opts is not deprecated. getOptions is

@boneskull
Copy link
Contributor

might be able to salvage those tests though

@boneskull
Copy link
Contributor

and fwiw most of the churn on the yargs PR involves the fact that .mochajs.yml DOES allow node options, since mocha.opts did. there’s not much practical difference between any of them.

@boneskull
Copy link
Contributor

...it was hard to get right.

@plroebuck
Copy link
Contributor Author

and fwiw most of the churn on the yargs PR involves the fact that .mochajs.yml DOES allow node
options, since mocha.opts did. there’s not much practical difference between any of them.

I'd have left "mocha.opts" for passing Node flags, and "mocha.yml" strictly for Mocha options, once tranformed to JSON, ready to be passed directly to the ctor. Non-Node flags found in "mocha.opts" would produce a one-time warning to migrate them to "mocha.yml" with list of offending.

@boneskull
Copy link
Contributor

I'd have left "mocha.opts" for passing Node flags, and "mocha.yml" strictly for Mocha options, once tranformed to JSON, ready to be passed directly to the ctor. Non-Node flags found in "mocha.opts" would produce a one-time warning to migrate them to "mocha.yml" with list of offending.

imo this seems like a pain in the butt for users--requiring two config files. if we want users to stop using mocha.opts and use config files (which is something I want, anyway), then we need a workaround for this stuff. Anyway, it's done.

@boneskull
Copy link
Contributor

boneskull commented Dec 7, 2018

I'm going to see what of this I can salvage.

@boneskull
Copy link
Contributor

@plroebuck I've squashed this into a single commit, then rebased #3556 onto it; see 924e63c. I'll leave open for now unless there's something that needs to be added to this, but it looks fine to me. I was able to pull it all in, with some modifications of course.

@boneskull
Copy link
Contributor

I'm going to close this as it's been merged in 7a3e745.

@boneskull boneskull closed this Dec 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: usability concerning user experience or interface semver-major implementation requires increase of "major" version number; "breaking changes"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants