testaro 43.0.2 → 44.0.0
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-main.js +1405 -0
- package/run.js +46 -17
- package/tests/testaro.js +1 -1
package/run.js
CHANGED
|
@@ -76,6 +76,13 @@ const errorWords = [
|
|
|
76
76
|
'violates',
|
|
77
77
|
'warning'
|
|
78
78
|
];
|
|
79
|
+
// Time limits on tools.
|
|
80
|
+
const timeLimits = {
|
|
81
|
+
alfa: 20,
|
|
82
|
+
ed11y: 30,
|
|
83
|
+
ibm: 30,
|
|
84
|
+
testaro: 60
|
|
85
|
+
};
|
|
79
86
|
|
|
80
87
|
// ########## VARIABLES
|
|
81
88
|
|
|
@@ -502,7 +509,7 @@ const abortActs = async (report, actIndex) => {
|
|
|
502
509
|
report.jobData.abortedAct = actIndex;
|
|
503
510
|
report.jobData.aborted = true;
|
|
504
511
|
// Report that the job is aborted.
|
|
505
|
-
console.log(
|
|
512
|
+
console.log(`ERROR: Job aborted on act ${actIndex}`);
|
|
506
513
|
// Return an abortive act index.
|
|
507
514
|
return -2;
|
|
508
515
|
};
|
|
@@ -527,7 +534,6 @@ const addError = async(alsoLog, alsoAbort, report, actIndex, message) => {
|
|
|
527
534
|
}
|
|
528
535
|
// If the job is to be aborted:
|
|
529
536
|
if (alsoAbort) {
|
|
530
|
-
console.log(`report:\n${JSON.stringify(report, null, 2)}`);
|
|
531
537
|
// Return an abortive act index.
|
|
532
538
|
return await abortActs(report, actIndex);
|
|
533
539
|
}
|
|
@@ -816,23 +822,46 @@ const doActs = async (report, actIndex, page) => {
|
|
|
816
822
|
});
|
|
817
823
|
// Get the start time of the act.
|
|
818
824
|
const startTime = Date.now();
|
|
819
|
-
|
|
825
|
+
let timer;
|
|
820
826
|
try {
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
827
|
+
// Impose a time limit on the act.
|
|
828
|
+
let timeoutReport = 'onTime';
|
|
829
|
+
const timeLimit = 1000 * timeLimits[act.which] || 15000;
|
|
830
|
+
timeoutReport = new Promise(resolve => {
|
|
831
|
+
timer = setTimeout(() => {
|
|
832
|
+
act.data = {
|
|
833
|
+
prevented: true,
|
|
834
|
+
error: `Act timed out at ${timeLimit / 1000} seconds`
|
|
835
|
+
};
|
|
836
|
+
console.log(`ERROR: Timed out at ${timeLimit / 1000} seconds`);
|
|
837
|
+
resolve('timedOut');
|
|
838
|
+
}, timeLimit);
|
|
839
|
+
});
|
|
840
|
+
// Try to perform the specified tests of the tool and get a report.
|
|
841
|
+
const actReport = require(`./tests/${act.which}`).reporter(page, options);
|
|
842
|
+
const raceReport = await Promise.race([timeoutReport, actReport]);
|
|
843
|
+
// If the act was finished without timing out:
|
|
844
|
+
if (raceReport !== 'timedOut') {
|
|
845
|
+
// Disable the timer.
|
|
846
|
+
clearTimeout(timer);
|
|
847
|
+
// Import the test results and process data into the act.
|
|
848
|
+
act.result = raceReport && raceReport.result || {};
|
|
849
|
+
act.data = raceReport && raceReport.data || {};
|
|
850
|
+
// If the page prevented the tool from operating:
|
|
851
|
+
if (act.data.prevented) {
|
|
852
|
+
// Add prevention data to the job data.
|
|
853
|
+
report.jobData.preventions[act.which] = act.data.error;
|
|
854
|
+
}
|
|
829
855
|
}
|
|
830
856
|
}
|
|
831
|
-
// If the testing failed:
|
|
857
|
+
// If the testing failed other than by timing out:
|
|
832
858
|
catch(error) {
|
|
833
|
-
//
|
|
859
|
+
// Disable the timer.
|
|
860
|
+
clearTimeout(timer);
|
|
861
|
+
// Report the failure.
|
|
834
862
|
const message = error.message.slice(0, 400);
|
|
835
863
|
console.log(`ERROR: Test act ${act.which} failed (${message})`);
|
|
864
|
+
act.data.prevented = true;
|
|
836
865
|
act.data.error = act.data.error ? `${act.data.error}; ${message}` : message;
|
|
837
866
|
}
|
|
838
867
|
// Add the elapsed time of the tool to the report.
|
|
@@ -842,9 +871,9 @@ const doActs = async (report, actIndex, page) => {
|
|
|
842
871
|
toolTimes[act.which] = 0;
|
|
843
872
|
}
|
|
844
873
|
toolTimes[act.which] += time;
|
|
845
|
-
// If
|
|
874
|
+
// If the act was not prevented and standardization is required:
|
|
846
875
|
const standard = report.standard || 'only';
|
|
847
|
-
if (['also', 'only'].includes(standard)) {
|
|
876
|
+
if (! act.data.prevented && ['also', 'only'].includes(standard)) {
|
|
848
877
|
// Initialize it.
|
|
849
878
|
act.standardResult = {
|
|
850
879
|
totals: [0, 0, 0, 0],
|
|
@@ -868,9 +897,9 @@ const doActs = async (report, actIndex, page) => {
|
|
|
868
897
|
delete act.result;
|
|
869
898
|
}
|
|
870
899
|
}
|
|
871
|
-
// If the act has expectations:
|
|
900
|
+
// If the act was not prevented and has expectations:
|
|
872
901
|
const expectations = act.expect;
|
|
873
|
-
if (expectations) {
|
|
902
|
+
if (! act.data.prevented && expectations) {
|
|
874
903
|
// Initialize whether they were fulfilled.
|
|
875
904
|
act.expectations = [];
|
|
876
905
|
let failureCount = 0;
|
package/tests/testaro.js
CHANGED
|
@@ -206,8 +206,8 @@ exports.reporter = async (page, options) => {
|
|
|
206
206
|
result[rule] = {};
|
|
207
207
|
}
|
|
208
208
|
result[rule].what = what;
|
|
209
|
+
const startTime = Date.now();
|
|
209
210
|
try {
|
|
210
|
-
const startTime = Date.now();
|
|
211
211
|
// Apply a 15-second time limit to the test. If it expires:
|
|
212
212
|
let timeout;
|
|
213
213
|
const timer = new Promise(resolve => {
|