testaro 58.0.10 → 58.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/run.js +23 -7
package/package.json
CHANGED
package/run.js
CHANGED
|
@@ -569,26 +569,42 @@ const abortActs = (report, actIndex) => {
|
|
|
569
569
|
console.log(`ERROR: Job aborted on act ${actIndex}`);
|
|
570
570
|
};
|
|
571
571
|
// Performs the acts in a report and adds the results to the report.
|
|
572
|
-
const doActs = async (report) => {
|
|
572
|
+
const doActs = async (report, opts = {}) => {
|
|
573
573
|
const {acts} = report;
|
|
574
|
+
const {onProgress = null, signal = null} = opts;
|
|
574
575
|
// Get the standardization specification.
|
|
575
576
|
const standard = report.standard || 'only';
|
|
576
577
|
const reportPath = `${tmpDir}/report.json`;
|
|
577
578
|
// For each act in the report.
|
|
578
579
|
for (const doActsIndex in acts) {
|
|
580
|
+
if (signal && signal.aborted) throw new Error('doActs aborted');
|
|
579
581
|
actIndex = doActsIndex;
|
|
580
582
|
// If the job has not been aborted:
|
|
581
583
|
if (report.jobData && ! report.jobData.aborted) {
|
|
582
584
|
let act = acts[actIndex];
|
|
583
585
|
const {type, which} = act;
|
|
584
|
-
const actSuffix = type === 'test' ? ` ${which}` : '';
|
|
585
|
-
const message = `>>>> ${type}${actSuffix}`;
|
|
586
586
|
// If granular reporting has been specified:
|
|
587
587
|
if (report.observe) {
|
|
588
|
-
//
|
|
588
|
+
// If a progress callback has been provided:
|
|
589
589
|
const whichParam = which ? `&which=${which}` : '';
|
|
590
590
|
const messageParams = `act=${type}${whichParam}`;
|
|
591
|
-
|
|
591
|
+
if (onProgress) {
|
|
592
|
+
// Notify the observer of the act.
|
|
593
|
+
try {
|
|
594
|
+
onProgress({
|
|
595
|
+
type,
|
|
596
|
+
which
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
catch (error) {}
|
|
600
|
+
}
|
|
601
|
+
// Otherwise, i.e. if no progress callback has been provided:
|
|
602
|
+
else {
|
|
603
|
+
const actSuffix = type === 'test' ? ` ${which}` : '';
|
|
604
|
+
const message = `>>>> ${type}${actSuffix}`;
|
|
605
|
+
// Notify the observer of the act and log it.
|
|
606
|
+
tellServer(report, messageParams, message);
|
|
607
|
+
}
|
|
592
608
|
}
|
|
593
609
|
// Otherwise, i.e. if granular reporting has not been specified:
|
|
594
610
|
else {
|
|
@@ -1386,7 +1402,7 @@ const doActs = async (report) => {
|
|
|
1386
1402
|
return report;
|
|
1387
1403
|
};
|
|
1388
1404
|
// Runs a job and returns a report.
|
|
1389
|
-
exports.doJob = async job => {
|
|
1405
|
+
exports.doJob = async (job, opts = {}) => {
|
|
1390
1406
|
// Make a report as a copy of the job.
|
|
1391
1407
|
let report = JSON.parse(JSON.stringify(job));
|
|
1392
1408
|
const jobData = report.jobData = {};
|
|
@@ -1428,7 +1444,7 @@ exports.doJob = async job => {
|
|
|
1428
1444
|
});
|
|
1429
1445
|
// Perform the acts and get a report.
|
|
1430
1446
|
console.log('Performing the job acts');
|
|
1431
|
-
report = await doActs(report,
|
|
1447
|
+
report = await doActs(report, opts);
|
|
1432
1448
|
// Add the end time and duration to the report.
|
|
1433
1449
|
const endTime = new Date();
|
|
1434
1450
|
report.jobData.endTime = nowString();
|