-
-
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
Report non-match to STDERR and exit if no files are matched #2450
Conversation
if (err.message.indexOf('cannot resolve path') === 0) { | ||
console.error('Warning: Could not find any test files matching pattern: ' + arg); | ||
return; | ||
} else { |
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.
This else
is unnecessary.
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.
Isn't it good practice to re-throw any other error that might not be this specific one? Otherwise it will just be swallowed
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.
.. And now I get it. Was a bit distracted. Fixed
}); | ||
|
||
if (files.length === 0) { |
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.
prefer if (!files.length)
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.
(not required)
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.
Fixed
}); | ||
|
||
if (files.length === 0) { | ||
process.exit(1); |
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.
Should probably add an error message here about no files being found, given you can simply execute mocha
in a directory with empty subdir test
, and this is the current output:
$ mocha
0 passing (3ms)
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.
Fixed
…if no files are matched at all. Fixes #2194
1218f28
to
033f66a
Compare
@boneskull Changes implemented, branch rebased and all tests are passing |
Thanks @Munter |
…roperty-currentretry * upstream/master: helpful error when necessary suite callback omitted; closes mochajs#1744 Fix an issue and add relevant tests when describe and xdescribe fail when not supplied with a callback (issue mochajs#1744). rename more fixtures; closes mochajs#2383 Report non-match to STDERR and exit if no files are matched (mochajs#2450) Exit process with correct error codes (mochajs#2445) fix test files not using .spec suffix fix test fixtures not using .fixture suffix always halt execution when async skip() called; closes mochajs#2465 (mochajs#2479) avoid test flake in "delay" test; closes mochajs#2469 (mochajs#2470) revert accidental change to bin paths disregard function names when testing under Node.js 6.5.0; closes mochajs#2467 (mochajs#2477) lints more files; add more files to lint check; closes mochajs#2457 adds *.orig to .gitignore Exclude the --inspect flag fix check-leaks to catch a leak whose name begins with 'd'
…-files-cache * upstream/master: attempt windows-friendly reproducible case for mochajs#2315 fix: fix uncaught TypeError if error occurs on next tick, closes mochajs#2315 (mochajs#2439) helpful error when necessary suite callback omitted; closes mochajs#1744 Fix an issue and add relevant tests when describe and xdescribe fail when not supplied with a callback (issue mochajs#1744). rename more fixtures; closes mochajs#2383 Report non-match to STDERR and exit if no files are matched (mochajs#2450) Exit process with correct error codes (mochajs#2445) fix test files not using .spec suffix fix test fixtures not using .fixture suffix always halt execution when async skip() called; closes mochajs#2465 (mochajs#2479) avoid test flake in "delay" test; closes mochajs#2469 (mochajs#2470) revert accidental change to bin paths disregard function names when testing under Node.js 6.5.0; closes mochajs#2467 (mochajs#2477) lints more files; add more files to lint check; closes mochajs#2457 adds *.orig to .gitignore Exclude the --inspect flag fix check-leaks to catch a leak whose name begins with 'd'
…2450) * Report non-matching patterns to STDERR and exit with non-zero status if no files are matched at all. Fixes mochajs#2194 * Code review changes
This displays a warning on STDERR for each glob pattern that is passed in as a binary execution argument if the glob pattern results in no files matched.
If no files are matched across all the passed glob patterns it exits with error code 1
This allows for running tests for any glob pattern that correctly matches files, while still making the user aware of their other invalid glob patterns. Previously we would throw if any pattern did not match any files and the error message was not the best one to figure out the problem.
Fixes #2194