Innovenergy_trunk/frontend/node_modules/testcafe/lib/live/test-runner.js

174 lines
22 KiB
JavaScript

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = require("lodash");
const test_run_controller_1 = __importDefault(require("./test-run-controller"));
const controller_1 = __importDefault(require("./controller"));
const runner_1 = __importDefault(require("../runner"));
const bootstrapper_1 = __importDefault(require("./bootstrapper"));
const parse_file_list_1 = __importDefault(require("../utils/parse-file-list"));
const runtime_1 = require("../errors/runtime");
const types_1 = require("../errors/types");
class LiveModeRunner extends runner_1.default {
constructor({ proxy, browserConnectionGateway, configuration, compilerService }) {
super({ proxy, browserConnectionGateway, configuration, compilerService });
this.stopping = false;
this.runnerTaskPromise = null;
this.stopInfiniteWaiting = lodash_1.noop;
this.rejectInfiniteWaiting = lodash_1.noop;
this.assets = null;
this.testRunController = new test_run_controller_1.default();
this.controller = this._createController();
this.embeddingOptions({
TestRunCtor: this.testRunController.TestRunCtor,
assets: [],
});
this.controller = this._createController();
this.configurationCache = null;
}
runTests(isFirstRun = false) {
let runError = null;
return this._finishPreviousTestRuns()
.then(() => {
return this._validateRunnableConfiguration(isFirstRun);
})
.then(() => {
const expectedTestCount = this.configurationCache.tests.length;
this.testRunController.setExpectedTestCount(expectedTestCount);
})
.then(() => {
this.runnerTaskPromise = super.run(this.opts);
return this.runnerTaskPromise;
})
.catch(err => {
this.setBootstrappingError(null);
runError = err;
})
.then(() => {
this.runnerTaskPromise = null;
this.controller.onTestRunDone(runError);
});
}
_validateRunOptions() {
return super._validateRunOptions()
.catch(err => {
this.rejectInfiniteWaiting(err);
});
}
_createRunnableConfiguration() {
if (this.configurationCache)
return Promise.resolve(this.configurationCache);
return super._createRunnableConfiguration()
.then(configuration => {
this.configurationCache = configuration;
return configuration;
})
.catch(err => {
this.rejectInfiniteWaiting(err);
});
}
setBootstrappingError(err) {
this.bootstrappingError = err;
}
run(options) {
this.configurationCache = null;
if (this._running)
throw new runtime_1.GeneralError(types_1.RUNTIME_ERRORS.cannotRunLiveModeRunnerMultipleTimes);
this._running = this._waitUntilExit()
.then(() => {
return this._dispose();
})
.then(() => {
delete this._running;
});
this.opts = Object.assign({}, this.opts, options);
this._setConfigurationOptions()
.then(() => this._setBootstrapperOptions())
.then(() => (0, parse_file_list_1.default)(this.bootstrapper.sources, process.cwd()))
.then(files => {
return this.controller.init(files);
})
.then(() => this._createRunnableConfiguration())
.then(() => this.runTests(true));
return this._running;
}
suspend() {
if (!this.runnerTaskPromise)
return Promise.resolve();
this.stopping = true;
this.testRunController.stop();
this.runnerTaskPromise.cancel();
return this.testRunController.allTestsCompletePromise
.then(() => {
this.stopping = false;
this.controller.onTestRunDone();
});
}
stop() {
return super.stop()
.then(() => {
return this.controller.exit();
});
}
exit() {
if (this.runnerTaskPromise)
this.runnerTaskPromise.cancel();
return Promise.resolve()
.then(() => this.stopInfiniteWaiting())
.then(() => this._running);
}
async _finishPreviousTestRuns() {
var _a;
if (!((_a = this.configurationCache) === null || _a === void 0 ? void 0 : _a.tests))
return;
this.testRunController.run();
}
_validateRunnableConfiguration(isFirstRun) {
if (isFirstRun) {
if (this.bootstrappingError)
return Promise.reject(this.bootstrappingError);
else if (!this.configurationCache) {
// NOTE: Such errors handled in process.on('unhandledRejection') handler.
return Promise.reject(null);
}
return Promise.resolve();
}
return this.bootstrapper._getTests()
.then(tests => {
this.configurationCache.tests = tests;
return this.bootstrappingError ? Promise.reject(this.bootstrappingError) : Promise.resolve();
});
}
_createTask(tests, browserConnectionGroups, proxy, opts) {
opts.live = true;
return super._createTask(tests, browserConnectionGroups, proxy, opts, this.warningLog);
}
_createBootstrapper(browserConnectionGateway, compilerService, messageBus) {
return new bootstrapper_1.default(this, browserConnectionGateway, compilerService, messageBus);
}
_createController() {
return new controller_1.default(this);
}
_waitUntilExit() {
return new Promise((resolve, reject) => {
this.stopInfiniteWaiting = resolve;
this.rejectInfiniteWaiting = reject;
});
}
_disposeAssets(browserSet, reporters, testedApp) {
this.assets = { browserSet, reporters, testedApp };
return Promise.resolve();
}
_dispose() {
this.controller.dispose();
if (!this.assets)
return Promise.resolve();
const { browserSet, reporters, testedApp } = this.assets;
return super._disposeAssets(browserSet, reporters, testedApp);
}
}
exports.default = LiveModeRunner;
module.exports = exports.default;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC1ydW5uZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGl2ZS90ZXN0LXJ1bm5lci5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLG1DQUE4QjtBQUM5QixnRkFBOEQ7QUFDOUQsOERBQThDO0FBQzlDLHVEQUErQjtBQUMvQixrRUFBa0Q7QUFDbEQsK0VBQXFEO0FBQ3JELCtDQUFpRDtBQUNqRCwyQ0FBaUQ7QUFFakQsTUFBTSxjQUFlLFNBQVEsZ0JBQU07SUFDL0IsWUFBYSxFQUFFLEtBQUssRUFBRSx3QkFBd0IsRUFBRSxhQUFhLEVBQUUsZUFBZSxFQUFFO1FBQzVFLEtBQUssQ0FBQyxFQUFFLEtBQUssRUFBRSx3QkFBd0IsRUFBRSxhQUFhLEVBQUUsZUFBZSxFQUFFLENBQUMsQ0FBQztRQUUzRSxJQUFJLENBQUMsUUFBUSxHQUFnQixLQUFLLENBQUM7UUFDbkMsSUFBSSxDQUFDLGlCQUFpQixHQUFPLElBQUksQ0FBQztRQUNsQyxJQUFJLENBQUMsbUJBQW1CLEdBQUssYUFBSSxDQUFDO1FBQ2xDLElBQUksQ0FBQyxxQkFBcUIsR0FBRyxhQUFJLENBQUM7UUFFbEMsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLENBQUM7UUFFbkIsSUFBSSxDQUFDLGlCQUFpQixHQUFHLElBQUksNkJBQXlCLEVBQUUsQ0FBQztRQUN6RCxJQUFJLENBQUMsV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ICAgICAgICAgICAgICBjb25zdCBleHBlY3RlZFRlc3RDb3VudCA9IHRoaXMuY29uZmlndXJhdGlvbkNhY2hlLnRlc3RzLmxlbmd0aDtcblxuICAgICAgICAgICAgICAgIHRoaXMudGVzdFJ1bkNvbnRyb2xsZXIuc2V0RXhwZWN0ZWRUZXN0Q291bnQoZXhwZWN0ZWRUZXN0Q291bnQpO1xuICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIC50aGVuKCgpID0+IHtcbiAgICAgICAgICAgICAgICB0aGlzLnJ1bm5lclRhc2tQcm9taXNlID0gc3VwZXIucnVuKHRoaXMub3B0cyk7XG5cbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5ydW5uZXJUYXNrUHJvbWlzZTtcbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAuY2F0Y2goZXJyID0+IHtcbiAgICAgICAgICAgICAgICB0aGlzLnNldEJvb3RzdHJhcHBpbmdFcnJvcihudWxsKTtcblxuICAgICAgICAgICAgICAgIHJ1bkVycm9yID0gZXJyO1xuICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIC50aGVuKCgpID0+IHtcbiAgICAgICAgICAgICAgICB0aGlzLnJ1bm5lclRhc2tQcm9taXNlID0gbnVsbDtcblxuICAgICAgICAgICAgICAgIHRoaXMuY29udHJvbGxlci5vblRlc3RSdW5Eb25lKHJ1bkVycm9yKTtcbiAgICAgICAgICAgIH0pO1xuICAgIH1cblxuICAgIF92YWxpZGF0ZVJ1bk9wdGlvbnMgKCkge1xuICAgICAgICByZXR1cm4gc3VwZXIuX3ZhbGlkYXRlUnVuT3B0aW9ucygpXG4gICAgICAgICAgICAuY2F0Y2goZXJyID0+IHtcbiAgICAgICAgICAgICAgICB0aGlzLnJlamVjdEluZmluaXRlV2FpdGluZyhlcnIpO1xuICAgICAgICAgICAgfSk7XG4gICAgfVxuXG4gICAgX2NyZWF0ZVJ1bm5hYmxlQ29uZmlndXJhdGlvbiAoKSB7XG4gICAgICAgIGlmICh0aGlzLmNvbmZpZ3VyYXRpb25DYWNoZSlcbiAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlc29sdmUodGhpcy5jb25maWd1cmF0aW9uQ2FjaGUpO1xuXG4gICAgICAgIHJldHVybiBzdXBlci5fY3JlYXRlUnVubmFibGVDb25maWd1cmF0aW9uKClcbiAgICAgICAgICAgIC50aGVuKGNvbmZpZ3VyYXRpb24gPT4ge1xuICAgICAgICAgICAgICAgIHRoaXMuY29uZmlndXJhdGlvbkNhY2hlID0gY29uZmlndXJhdGlvbjtcblxuICAgICAgICAgICAgICAgIHJldHVybiBjb25maWd1cmF0aW9uO1xuICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIC5jYXRjaChlcnIgPT4ge1xuICAgICAgICAgICAgICAgIHRoaXMucmVqZWN0SW5maW5pdGVXYWl0aW5nKGVycik7XG4gICAgICAgICAgICB9KTtcbiAgICB9XG5cbiAgICBzZXRCb290c3RyYXBwaW5nRXJyb3IgKGVycikge1xuICAgICAgICB0aGlzLmJvb3RzdHJhcHBpbmdFcnJvciA9IGVycjtcbiAgICB9XG5cbiAgICBydW4gKG9wdGlvbnMpIHtcbiAgICAgICAgdGhpcy5jb25maWd1cmF0aW9uQ2FjaGUgPSBudWxsO1xuXG4gICAgICAgIGlmICh0aGlzLl9ydW5uaW5nKVxuICAgICAgICAgICAgdGhyb3cgbmV3IEdlbmVyYWxFcnJvcihSVU5USU1FX0VSUk9SUy5jYW5ub3RSdW5MaXZlTW9kZVJ1bm5lck11bHRpcGxlVGltZXMpO1xuXG4gICAgICAgIHRoaXMuX3J1bm5pbmcgPSB0aGlzLl93YWl0VW50aWxFeGl0KClcbiAgICAgICAgICAgIC50aGVuKCgpID0+IHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fZGlzcG9zZSgpO1xuICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIC50aGVuKCgpID0+IHtcbiAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5fcnVubmluZztcb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0b3BwaW5nID0gZmFsc2U7XG5cbiAgICAgICAgICAgICAgICB0aGlzLmNvbnRyb2xsZXIub25UZXN0UnVuRG9uZSgpO1xuICAgICAgICAgICAgfSk7XG4gICAgfVxuXG4gICAgc3RvcCAoKSB7XG4gICAgICAgIHJldHVybiBzdXBlci5zdG9wKClcbiAgICAgICAgICAgIC50aGVuKCgpID0+IHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250cm9sbGVyLmV4aXQoKTtcbiAgICAgICAgICAgIH0pO1xuICAgIH1cblxuICAgIGV4aXQgKCkge1xuICAgICAgICBpZiAodGhpcy5ydW5uZXJUYXNrUHJvbWlzZSlcbiAgICAgICAgICAgIHRoaXMucnVubmVyVGFza1Byb21pc2UuY2FuY2VsKCk7XG5cbiAgICAgICAgcmV0dXJuIFByb21pc2UucmVzb2x2ZSgpXG4gICAgICAgICAgICAudGhlbigoKSA9PiB0aGlzLnN0b3BJbmZpbml0ZVdhaXRpbmcoKSlcbiAgICAgICAgICAgIC50aGVuKCgpID0+IHRoaXMuX3J1bm5pbmcpO1xuICAgIH1cblxuICAgIGFzeW5jIF9maW5pc2hQcmV2aW91c1Rlc3RSdW5zICgpIHtcbiAgICAgICAgaWYgKCF0aGlzLmNvbmZpZ3VyYXRpb25DYWNoZT8udGVzdHMpIHJldHVybjtcblxuICAgICAgICB0aGlzLnRlc3RSdW5Db250cm9sbGVyLnJ1bigpO1xuICAgIH1cblxuICAgIF92YWxpZGF0ZVJ1bm5hYmxlQ29uZmlndXJhdGlvbiAoaXNGaXJzdFJ1bikge1xuICAgICAgICBpZiAoaXNGaXJzdFJ1bikge1xuICAgICAgICAgICAgaWYgKHRoaXMuYm9vdHN0cmFwcGluZ0Vycm9yKVxuICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdCh0aGlzLmJvb3RzdHJhcHBpbmdFcnJvcik7XG5cbiAgICAgICAgICAgIGVsc2UgaWYgKCF0aGlzLmNvbmZpZ3VyYXRpb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