perst
Version:
perst is a wrapper around LoaderIO, which can be configured and run in your commandline multiple tests and validates the measureable values like AVG Response Time and AVG Error Rate.
34 lines (28 loc) • 820 B
JavaScript
import Task from '../Task/Task.js';
/**
*
* @param {Object} config
* @param {Task[]} tasks
* @return {Promise<number>}
*/
async function run(config, tasks) {
let failed = false;
// run the tasks in sequential
await tasks.reduce(
(promise, task) => {
return promise.then(
async () => {
if (config.stopOnFailure === false || failed === false) {
await task.run();
failed = task.result === Task.RESULT.FAILED;
}
return task;
}
);
},
Promise.resolve()
);
// exit with process exit state
return tasks.find((task) => task.result === Task.RESULT.FAILED) !== undefined ? 1 : 0;
}
export { run as default };