UNPKG

@intuitionrobotics/testelot

Version:
59 lines 2.46 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AppTester = void 0; const ts_common_1 = require("@intuitionrobotics/ts-common"); const __1 = require(".."); class AppTester extends ts_common_1.ModuleManager { constructor() { super(); this.reporter = new __1.Reporter(); this.runTestsImpl = () => __awaiter(this, void 0, void 0, function* () { if (!this.scenario) throw new ts_common_1.ImplementationMissingException("No test specified!!"); this.prepare(); this.init(); this.reporter.init(); __1.Action.resolveTestsToRun(); const scenario = (0, __1.__scenario)("root", this.reporter); scenario.add(this.scenario); yield scenario.run(); }); } setScenario(scenario) { this.scenario = scenario; return this; } build() { const pwd = process.env.PWD; let packageName; if (pwd) packageName = pwd.substring(pwd.lastIndexOf("/") + 1); this.runTestsImpl() .then(() => { const errorCount = this.reporter.summary.Error; if (errorCount > 0) { this.logError(`Package: ${packageName} - Tests ended with ${errorCount} ${errorCount === 1 ? "error" : "errors"}`); process.exit(2); } this.logInfo(`Package: ${packageName} - Tests completed successfully`); process.exit(0); }) .catch(reason => { this.logError(`Package: ${packageName} - Tests failed`, reason); process.exit(3); }); } prepare() { } } exports.AppTester = AppTester; //# sourceMappingURL=AppTester.js.map