Skip to content

Commit

Permalink
precompile helpers and fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
vdemedes committed Oct 15, 2016
1 parent e10338e commit 600f1d3
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module.exports = Api;

Api.prototype._runFile = function (file, runStatus, execArgv) {
var hash = this.precompiler.precompileFile(file);
var precompiled = {};
var precompiled = objectAssign({}, this._precompiledHelpers);
precompiled[file] = hash;

var options = objectAssign({}, this.options, {
Expand Down Expand Up @@ -130,7 +130,22 @@ Api.prototype._setupPrecompiler = function (files) {
this.precompiler = new CachingPrecompiler(cacheDir, this.options.babelConfig, isPowerAssertEnabled);
};

Api.prototype._precompileHelpers = function () {
var self = this;

this._precompiledHelpers = {};

return new AvaFiles({cwd: this.options.resolveTestsFrom})
.findTestDependencies()
.map(function (file) { // eslint-disable-line array-callback-return
var hash = self.precompiler.precompileFile(file);
self._precompiledHelpers[file] = hash;
});
};

Api.prototype._run = function (files, options) {
var self = this;

options = options || {};

var runStatus = new RunStatus({
Expand All @@ -150,20 +165,23 @@ Api.prototype._run = function (files, options) {

this._setupPrecompiler(files);

if (this.options.timeout) {
this._setupTimeout(runStatus);
}
return this._precompileHelpers()
.then(function () {
if (self.options.timeout) {
self._setupTimeout(runStatus);
}

var overwatch;
if (this.options.concurrency > 0) {
var concurrency = this.options.serial ? 1 : this.options.concurrency;
overwatch = this._runWithPool(files, runStatus, concurrency);
} else {
// _runWithoutPool exists to preserve legacy behavior, specifically around `.only`
overwatch = this._runWithoutPool(files, runStatus);
}
var overwatch;
if (self.options.concurrency > 0) {
var concurrency = self.options.serial ? 1 : self.options.concurrency;
overwatch = self._runWithPool(files, runStatus, concurrency);
} else {
// _runWithoutPool exists to preserve legacy behavior, specifically around `.only`
overwatch = self._runWithoutPool(files, runStatus);
}

return overwatch;
return overwatch;
});
};

Api.prototype._computeForkExecArgs = function (files) {
Expand Down

0 comments on commit 600f1d3

Please sign in to comment.