Skip to content

Commit

Permalink
feat: Fail on launcher-, reporter-, or preprocessor-load errors.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
srawlins authored and budde377 committed Feb 23, 2016
1 parent d3bec1e commit dfcba5c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ var Launcher = function (emitter, injector) {
var browser = injector.createChild([locals], ['launcher:' + name]).get('launcher:' + name)
} catch (e) {
if (e.message.indexOf('No provider for "launcher:' + name + '"') !== -1) {
log.warn('Can not load "%s", it is not registered!\n ' +
'Perhaps you are missing some plugin?', name)
log.error('Cannot load browser "%s": it is not registered! ' +
'Perhaps you are missing some plugin?', name)
} else {
log.warn('Can not load "%s"!\n ' + e.stack, name)
log.error('Cannot load browser "%s"!\n ' + e.stack, name)
}

return
emitter.emit('load_error', 'launcher', name);
return;
}

// TODO(vojta): remove in v1.0 (BC for old launchers)
Expand Down
11 changes: 11 additions & 0 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ var Server = function (cliOptions, done) {

this.log = logger.create()

this.loadErrors = []

var config = cfg.parseConfig(cliOptions.configFile, cliOptions)

var modules = [{
Expand Down Expand Up @@ -135,6 +137,10 @@ Server.prototype._start = function (config, launcher, preprocess, fileList, webS

self._fileList = fileList

this.on('load_error', function(type, name) {
self.loadErrors.push([type, name])
})

config.frameworks.forEach(function (framework) {
self._injector.get('framework:' + framework)
})
Expand Down Expand Up @@ -175,6 +181,11 @@ Server.prototype._start = function (config, launcher, preprocess, fileList, webS
singleRunDoneBrowsers[browserLauncher.id] = false
})
}

if (self.loadErrors.length > 0) {
// At least one plugin failed to load.
process.exit(1)
}
})
}

Expand Down

0 comments on commit dfcba5c

Please sign in to comment.