-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat: Fail on launcher-, reporter-, or preprocessor-load errors. #1239
feat: Fail on launcher-, reporter-, or preprocessor-load errors. #1239
Conversation
@@ -27,6 +27,11 @@ var log = logger.create(); | |||
var start = function(injector, config, launcher, globalEmitter, preprocess, fileList, webServer, | |||
capturedBrowsers, socketServer, executor, done) { | |||
|
|||
var loadErrors = []; | |||
globalEmitter.on('load_error', function(type, name) { | |||
loadErrors.push([type, name]); |
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.
As each error is caught, they are collected here. After this, however, I can't figure out where to perform a final check of whether loadErrors
is empty or not...
Karma should fail if any plugin can't be instantiated. That is: launcher, preprocessor, reporter. Btw, I like the idea of collecting all errors and then failing, so that user sees all the errors and not only the first one. Here are all the places where Karma instantiate plugins and thus a fatal error can happen (in order in which it happens):
Thus, I would add the check into the webserver listener, after launching browsers (), and fail Karma if any error occurred. At that point, all of the plugins were instantiated, except preprocessors. We need to change preprocessors to instantiate all needed preprocessors ahead (in the I'm sorry this is confusing. I think it would be good to refactor Karma to instantiate everything first. Right now, "instantiating things" is kind of tangled together with bootstrapping (this is probably more efficient, but harder to understand). I wish I did it differently;-) @srawlins Let me know if I can help you more. This is very valuable work you are doing! |
@srawlins any chance for you updating this PR with the suggestions from @vojtajina. I would really appreciate it and I promise a shorter feedback cycle! |
Hi Friedel, i'm actually on vacation until June 20. Please feel free to
|
Thanks @srawlins for the quick answer, I'll see where we're at until June the 20th and update this pr if I get to doing it myself before. |
hey @srawlins any news on you getting back? |
Fail out of karma if a launcher, reporter, or preprocessor fails to load, after attempting to load each of them, and reporting errors for each load error. Closes karma-runner#855
3e6900f
to
73432eb
Compare
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
Hi @dignifiedquire , I've updated this with @vojtajina's suggestions, and it's working great! There's one problem though: I've changed the signature of var createPreprocessor = function(config, basePath, injector, emitter) { Travis revealed this as a problem, I think specifically with the karma-browserify which calls |
var alreadyDisplayedWarnings = Object.create(null) | ||
var createPreprocessor = function(config, basePath, injector, emitter) { | ||
var patterns = Object.keys(config); | ||
var alreadyDisplayedErrors = Object.create(null); |
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 use {}
instead
As far as I understand this di business, there should be no issue changing the signature, as it's only used as a factory function, which receives it's arguments through the injector |
Yeah, I think you're right. Unfortunately, karma-browserify calls |
@srawlins any updates? |
Closing to try to work this another way with #1931 |
Fail out of karma if a launcher, reporter, or preprocessor fails to load, after attempting to load each of them, and reporting errors for each load error.
Update
This PR is now ready, barring the issue with changing the signature of
createPreprocessor
that I highlight below. I did not add any tests, but would be happy to if someone could point me the way there.Example
I put the following into a config file:
and started karma:
then karma promptly exits.
Closes #855