testaro 43.0.3 → 44.0.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 +45 -15
- package/tests/testaro.js +1 -1
package/package.json
CHANGED
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
|
|
|
@@ -815,23 +822,46 @@ const doActs = async (report, actIndex, page) => {
|
|
|
815
822
|
});
|
|
816
823
|
// Get the start time of the act.
|
|
817
824
|
const startTime = Date.now();
|
|
818
|
-
|
|
825
|
+
let timer;
|
|
819
826
|
try {
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
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
|
+
}
|
|
828
855
|
}
|
|
829
856
|
}
|
|
830
|
-
// If the testing failed:
|
|
857
|
+
// If the testing failed other than by timing out:
|
|
831
858
|
catch(error) {
|
|
832
|
-
//
|
|
859
|
+
// Disable the timer.
|
|
860
|
+
clearTimeout(timer);
|
|
861
|
+
// Report the failure.
|
|
833
862
|
const message = error.message.slice(0, 400);
|
|
834
863
|
console.log(`ERROR: Test act ${act.which} failed (${message})`);
|
|
864
|
+
act.data.prevented = true;
|
|
835
865
|
act.data.error = act.data.error ? `${act.data.error}; ${message}` : message;
|
|
836
866
|
}
|
|
837
867
|
// Add the elapsed time of the tool to the report.
|
|
@@ -841,9 +871,9 @@ const doActs = async (report, actIndex, page) => {
|
|
|
841
871
|
toolTimes[act.which] = 0;
|
|
842
872
|
}
|
|
843
873
|
toolTimes[act.which] += time;
|
|
844
|
-
// If
|
|
874
|
+
// If the act was not prevented and standardization is required:
|
|
845
875
|
const standard = report.standard || 'only';
|
|
846
|
-
if (['also', 'only'].includes(standard)) {
|
|
876
|
+
if (! act.data.prevented && ['also', 'only'].includes(standard)) {
|
|
847
877
|
// Initialize it.
|
|
848
878
|
act.standardResult = {
|
|
849
879
|
totals: [0, 0, 0, 0],
|
|
@@ -867,9 +897,9 @@ const doActs = async (report, actIndex, page) => {
|
|
|
867
897
|
delete act.result;
|
|
868
898
|
}
|
|
869
899
|
}
|
|
870
|
-
// If the act has expectations:
|
|
900
|
+
// If the act was not prevented and has expectations:
|
|
871
901
|
const expectations = act.expect;
|
|
872
|
-
if (expectations) {
|
|
902
|
+
if (! act.data.prevented && expectations) {
|
|
873
903
|
// Initialize whether they were fulfilled.
|
|
874
904
|
act.expectations = [];
|
|
875
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 => {
|