testaro 5.17.1 → 5.17.2

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.
Files changed (2) hide show
  1. package/create.js +32 -16
  2. package/package.json +1 -1
package/create.js CHANGED
@@ -26,8 +26,10 @@ const timeoutHosts = [];
26
26
  // ########## VARIABLES
27
27
 
28
28
  let healthy = true;
29
+ // Set 5 minutes as a default time limit per host script.
29
30
  let timeLimit = 300;
30
31
  let reportCount = 0;
32
+ let specCount = Infinity;
31
33
 
32
34
  // ########## FUNCTIONS
33
35
 
@@ -46,12 +48,19 @@ const runHost = async (id, script) => {
46
48
  };
47
49
  // Recursively runs host scripts.
48
50
  const runHosts = async (timeStamp, specs) => {
49
- // If any scripts remain to be run and the process has not been interrupted:
51
+ if (specs.length >= specCount) {
52
+ console.log(`ERROR: Tried to run again with host count ${specs.length}`);
53
+ return;
54
+ }
55
+ else {
56
+ specCount = specs.length;
57
+ }
58
+ // If any host scripts remain to be run and the process has not been interrupted:
50
59
  if (specs.length && healthy) {
51
- // Run the first one and save the report with a host-suffixed ID.
60
+ // Remove the first host script from the list.
52
61
  const spec = specs.shift();
53
62
  const {id, host, script} = spec;
54
- // Fork a child process to run the script for that host.
63
+ // Fork a child process to run that host script.
55
64
  const subprocess = fork(
56
65
  'runHost', [id, JSON.stringify(script), JSON.stringify(host)],
57
66
  {
@@ -60,18 +69,20 @@ const runHosts = async (timeStamp, specs) => {
60
69
  }
61
70
  );
62
71
  let runMoreTimer = null;
63
- // If the child process times out:
72
+ // Let it run until it ends or, if the script or default time limit expires:
64
73
  const timer = setTimeout(async () => {
65
74
  clearTimeout(timer);
66
- // Record the host as timed out.
75
+ // Record the host script as timed out.
67
76
  timeoutHosts.push(id);
68
77
  // Kill the child process.
69
78
  subprocess.kill('SIGKILL');
70
- console.log(`Script for host ${id} exceeded ${timeLimit}-second time limit, so was killed`);
71
- // Run the remaining host scripts after a 10-second wait.
79
+ console.log(`Script for host ${id} took more than ${timeLimit} seconds, so was killed`);
80
+ // Wait 10 seconds. Then:
72
81
  runMoreTimer = setTimeout(async () => {
73
82
  clearTimeout(runMoreTimer);
83
+ // If the timeout did not coincide with the termination of the script:
74
84
  if (! (successHosts.includes(id) || crashHosts.includes(id))) {
85
+ // Run the remaining host scripts.
75
86
  console.log('Continuing with the remaining host scripts');
76
87
  await runHosts(timeStamp, specs);
77
88
  }
@@ -91,15 +102,20 @@ const runHosts = async (timeStamp, specs) => {
91
102
  });
92
103
  // If the child process ends:
93
104
  subprocess.on('exit', async () => {
94
- // If its end was not due to success or a timeout:
95
- if (! (successHosts.includes(id) || timeoutHosts.includes(id))) {
96
- clearTimeout(runMoreTimer);
97
- clearTimeout(timer);
98
- crashHosts.push(id);
99
- console.log(`Script for host ${id} crashed`);
100
- // Run the remaining host scripts.
101
- await runHosts(timeStamp, specs);
102
- }
105
+ // Wait 5 seconds, then:
106
+ const postExitTimer = setTimeout(async () => {
107
+ clearTimeout(postExitTimer);
108
+ // If its end was not due to success or a timeout:
109
+ if (! (successHosts.includes(id) || timeoutHosts.includes(id))) {
110
+ clearTimeout(runMoreTimer);
111
+ clearTimeout(timer);
112
+ // Record the host as having crashed.
113
+ crashHosts.push(id);
114
+ console.log(`Script for host ${id} crashed`);
115
+ // Run the remaining host scripts.
116
+ await runHosts(timeStamp, specs);
117
+ }
118
+ }, 5000);
103
119
  });
104
120
  }
105
121
  // Otherwise, i.e. if no more host scripts are to be run:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "5.17.1",
3
+ "version": "5.17.2",
4
4
  "description": "Automation of accessibility testing",
5
5
  "main": "index.js",
6
6
  "scripts": {