testaro 8.5.2 → 9.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.
Files changed (45) hide show
  1. package/README.md +94 -155
  2. package/{commands.js → actSpecs.js} +1 -1
  3. package/call.js +35 -13
  4. package/package.json +2 -3
  5. package/run.js +99 -148
  6. package/samples/00000-ts18-example.json +3 -3
  7. package/validation/executors/run.js +40 -0
  8. package/validation/executors/watchDir.js +7 -6
  9. package/validation/executors/watchNet.js +5 -6
  10. package/validation/jobs/done/README.md +3 -0
  11. package/validation/jobs/{00000-simple-example.json → todo/00000-simple-example.json} +6 -7
  12. package/validation/jobs/{README.md → todo/README.md} +0 -0
  13. package/validation/tests/jobs/allHidden.json +3 -2
  14. package/validation/tests/jobs/bulk.json +3 -2
  15. package/validation/tests/jobs/docType.json +3 -2
  16. package/validation/tests/jobs/elements.json +3 -2
  17. package/validation/tests/jobs/embAc.json +3 -2
  18. package/validation/tests/jobs/filter.json +3 -2
  19. package/validation/tests/jobs/focAll.json +3 -2
  20. package/validation/tests/jobs/focInd.json +3 -2
  21. package/validation/tests/jobs/focOp.json +3 -2
  22. package/validation/tests/jobs/focVis.json +3 -2
  23. package/validation/tests/jobs/hover.json +3 -2
  24. package/validation/tests/jobs/labClash.json +3 -2
  25. package/validation/tests/jobs/linkTo.json +3 -2
  26. package/validation/tests/jobs/linkUl.json +3 -2
  27. package/validation/tests/jobs/menuNav.json +3 -2
  28. package/validation/tests/jobs/miniText.json +3 -2
  29. package/validation/tests/jobs/motion.json +3 -2
  30. package/validation/tests/jobs/nonTable.json +3 -2
  31. package/validation/tests/jobs/radioSet.json +3 -2
  32. package/validation/tests/jobs/role.json +3 -2
  33. package/validation/tests/jobs/styleDiff.json +3 -2
  34. package/validation/tests/jobs/tabNav.json +3 -2
  35. package/validation/tests/jobs/textNodes.json +3 -2
  36. package/validation/tests/jobs/title.json +3 -2
  37. package/validation/tests/jobs/titledEl.json +3 -2
  38. package/validation/tests/jobs/zIndex.json +3 -2
  39. package/validation/validateTest.js +3 -8
  40. package/validation/watch/{README.md → done/README.md} +0 -0
  41. package/validation/watch/todo/README.md +3 -0
  42. package/watch.js +16 -22
  43. package/high.js +0 -60
  44. package/validation/executors/high.js +0 -52
  45. package/validation/executors/low.js +0 -53
@@ -2,7 +2,8 @@
2
2
  "id": "embAcVal",
3
3
  "what": "validation of embAc test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -48,6 +49,6 @@
48
49
  "host": {},
49
50
  "requester": ""
50
51
  },
51
- "jobCreationTime": "2002-11-12T09:31:00",
52
+ "creationTime": "2002-11-12T09:31:00",
52
53
  "timeStamp": "00000"
53
54
  }
@@ -2,7 +2,8 @@
2
2
  "id": "filterVal",
3
3
  "what": "validation of filter test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -49,6 +50,6 @@
49
50
  "host": {},
50
51
  "requester": ""
51
52
  },
52
- "jobCreationTime": "2002-11-12T09:31:00",
53
+ "creationTime": "2002-11-12T09:31:00",
53
54
  "timeStamp": "00000"
54
55
  }
@@ -2,7 +2,8 @@
2
2
  "id": "focAllVal",
3
3
  "what": "validation of focAll test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -62,6 +63,6 @@
62
63
  "host": {},
63
64
  "requester": ""
64
65
  },
65
- "jobCreationTime": "2002-11-12T09:31:00",
66
+ "creationTime": "2002-11-12T09:31:00",
66
67
  "timeStamp": "00000"
67
68
  }
@@ -2,7 +2,8 @@
2
2
  "id": "focIndVal",
3
3
  "what": "validation of focInd test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -63,6 +64,6 @@
63
64
  "host": {},
64
65
  "requester": ""
65
66
  },
66
- "jobCreationTime": "2002-11-12T09:31:00",
67
+ "creationTime": "2002-11-12T09:31:00",
67
68
  "timeStamp": "00000"
68
69
  }
@@ -2,7 +2,8 @@
2
2
  "id": "focOpVal",
3
3
  "what": "validation of focOp test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -56,6 +57,6 @@
56
57
  "host": {},
57
58
  "requester": ""
58
59
  },
59
- "jobCreationTime": "2002-11-12T09:31:00",
60
+ "creationTime": "2002-11-12T09:31:00",
60
61
  "timeStamp": "00000"
61
62
  }
@@ -2,7 +2,8 @@
2
2
  "id": "focVisVal",
3
3
  "what": "validation of focVis test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -29,6 +30,6 @@
29
30
  "host": {},
30
31
  "requester": ""
31
32
  },
32
- "jobCreationTime": "2002-11-12T09:31:00",
33
+ "creationTime": "2002-11-12T09:31:00",
33
34
  "timeStamp": "00000"
34
35
  }
@@ -2,7 +2,8 @@
2
2
  "id": "hoverVal",
3
3
  "what": "validation of hover test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -112,6 +113,6 @@
112
113
  "host": {},
113
114
  "requester": ""
114
115
  },
115
- "jobCreationTime": "2002-11-12T09:31:00",
116
+ "creationTime": "2002-11-12T09:31:00",
116
117
  "timeStamp": "00000"
117
118
  }
@@ -2,7 +2,8 @@
2
2
  "id": "labClashVal",
3
3
  "what": "validation of labClash test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -46,6 +47,6 @@
46
47
  "host": {},
47
48
  "requester": ""
48
49
  },
49
- "jobCreationTime": "2002-11-12T09:31:00",
50
+ "creationTime": "2002-11-12T09:31:00",
50
51
  "timeStamp": "00000"
51
52
  }
@@ -2,7 +2,8 @@
2
2
  "id": "linkToVal",
3
3
  "what": "validation of linkTo test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -29,6 +30,6 @@
29
30
  "host": {},
30
31
  "requester": ""
31
32
  },
32
- "jobCreationTime": "2002-11-12T09:31:00",
33
+ "creationTime": "2002-11-12T09:31:00",
33
34
  "timeStamp": "00000"
34
35
  }
@@ -2,7 +2,8 @@
2
2
  "id": "linkUlVal",
3
3
  "what": "validation of linkUl test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -65,6 +66,6 @@
65
66
  "host": {},
66
67
  "requester": ""
67
68
  },
68
- "jobCreationTime": "2002-11-12T09:31:00",
69
+ "creationTime": "2002-11-12T09:31:00",
69
70
  "timeStamp": "00000"
70
71
  }
@@ -2,7 +2,8 @@
2
2
  "id": "menuNavVal",
3
3
  "what": "validation of menuNav test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -100,6 +101,6 @@
100
101
  "host": {},
101
102
  "requester": ""
102
103
  },
103
- "jobCreationTime": "2002-11-12T09:31:00",
104
+ "creationTime": "2002-11-12T09:31:00",
104
105
  "timeStamp": "00000"
105
106
  }
@@ -2,7 +2,8 @@
2
2
  "id": "miniTextVal",
3
3
  "what": "validation of miniText test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -30,6 +31,6 @@
30
31
  "host": {},
31
32
  "requester": ""
32
33
  },
33
- "jobCreationTime": "2002-11-12T09:31:00",
34
+ "creationTime": "2002-11-12T09:31:00",
34
35
  "timeStamp": "00000"
35
36
  }
@@ -2,7 +2,8 @@
2
2
  "id": "motionVal",
3
3
  "what": "validation of motion test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "webkit",
@@ -56,6 +57,6 @@
56
57
  "host": {},
57
58
  "requester": ""
58
59
  },
59
- "jobCreationTime": "2002-11-12T09:31:00",
60
+ "creationTime": "2002-11-12T09:31:00",
60
61
  "timeStamp": "00000"
61
62
  }
@@ -2,7 +2,8 @@
2
2
  "id": "nonTableVal",
3
3
  "what": "validation of nonTable test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -31,6 +32,6 @@
31
32
  "host": {},
32
33
  "requester": ""
33
34
  },
34
- "jobCreationTime": "2002-11-12T09:31:00",
35
+ "creationTime": "2002-11-12T09:31:00",
35
36
  "timeStamp": "00000"
36
37
  }
@@ -2,7 +2,8 @@
2
2
  "id": "radioSetVal",
3
3
  "what": "validation of radioSet test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -46,6 +47,6 @@
46
47
  "host": {},
47
48
  "requester": ""
48
49
  },
49
- "jobCreationTime": "2002-11-12T09:31:00",
50
+ "creationTime": "2002-11-12T09:31:00",
50
51
  "timeStamp": "00000"
51
52
  }
@@ -2,7 +2,8 @@
2
2
  "id": "roleVal",
3
3
  "what": "validation of role test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -54,6 +55,6 @@
54
55
  "host": {},
55
56
  "requester": ""
56
57
  },
57
- "jobCreationTime": "2002-11-12T09:31:00",
58
+ "creationTime": "2002-11-12T09:31:00",
58
59
  "timeStamp": "00000"
59
60
  }
@@ -2,7 +2,8 @@
2
2
  "id": "styleDiffVal",
3
3
  "what": "validation of styleDiff test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -65,6 +66,6 @@
65
66
  "host": {},
66
67
  "requester": ""
67
68
  },
68
- "jobCreationTime": "2002-11-12T09:31:00",
69
+ "creationTime": "2002-11-12T09:31:00",
69
70
  "timeStamp": "00000"
70
71
  }
@@ -2,7 +2,8 @@
2
2
  "id": "tabNavVal",
3
3
  "what": "validation of tabNav test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -100,6 +101,6 @@
100
101
  "host": {},
101
102
  "requester": ""
102
103
  },
103
- "jobCreationTime": "2002-11-12T09:31:00",
104
+ "creationTime": "2002-11-12T09:31:00",
104
105
  "timeStamp": "00000"
105
106
  }
@@ -2,7 +2,8 @@
2
2
  "id": "elementsVal",
3
3
  "what": "validation of elements test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -92,6 +93,6 @@
92
93
  "host": {},
93
94
  "requester": ""
94
95
  },
95
- "jobCreationTime": "2002-11-12T09:31:00",
96
+ "creationTime": "2002-11-12T09:31:00",
96
97
  "timeStamp": "00000"
97
98
  }
@@ -2,7 +2,8 @@
2
2
  "id": "titleVal",
3
3
  "what": "validation of title test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -40,6 +41,6 @@
40
41
  "host": {},
41
42
  "requester": ""
42
43
  },
43
- "jobCreationTime": "2002-11-12T09:31:00",
44
+ "creationTime": "2002-11-12T09:31:00",
44
45
  "timeStamp": "00000"
45
46
  }
@@ -2,7 +2,8 @@
2
2
  "id": "titledElVal",
3
3
  "what": "validation of titledEl test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -31,6 +32,6 @@
31
32
  "host": {},
32
33
  "requester": ""
33
34
  },
34
- "jobCreationTime": "2002-11-12T09:31:00",
35
+ "creationTime": "2002-11-12T09:31:00",
35
36
  "timeStamp": "00000"
36
37
  }
@@ -2,7 +2,8 @@
2
2
  "id": "zIndexVal",
3
3
  "what": "validation of zIndex test",
4
4
  "strict": true,
5
- "commands": [
5
+ "timeLimit": 20,
6
+ "acts": [
6
7
  {
7
8
  "type": "launch",
8
9
  "which": "chromium",
@@ -43,6 +44,6 @@
43
44
  "host": {},
44
45
  "requester": ""
45
46
  },
46
- "jobCreationTime": "2002-11-12T09:31:00",
47
+ "creationTime": "2002-11-12T09:31:00",
47
48
  "timeStamp": "00000"
48
49
  }
@@ -2,18 +2,13 @@
2
2
  // Validator for one Testaro test.
3
3
 
4
4
  const fs = require('fs').promises;
5
- const {doJob} = require(`${__dirname}/../run`);
5
+ const {doJob} = require('../run');
6
6
  exports.validateTest = async testID => {
7
7
  const jobFileNames = await fs.readdir(`${__dirname}/tests/jobs`);
8
8
  for (const jobFileName of jobFileNames.filter(fileName => fileName === `${testID}.json`)) {
9
9
  const rawJobJSON = await fs.readFile(`${__dirname}/tests/jobs/${jobFileName}`, 'utf8');
10
10
  const jobJSON = rawJobJSON.replace(/__targets__/g, 'file://validation/tests/targets');
11
- const job = JSON.parse(jobJSON);
12
- const report = {
13
- job,
14
- acts: [],
15
- jobData: {}
16
- };
11
+ const report = JSON.parse(jobJSON);
17
12
  await doJob(report);
18
13
  const {acts, jobData} = report;
19
14
  if (jobData.endTime && /^\d{4}-.+$/.test(jobData.endTime)) {
@@ -24,7 +19,7 @@ exports.validateTest = async testID => {
24
19
  }
25
20
  const testActs = acts.filter(act => act.type && act.type === 'test');
26
21
  if (
27
- testActs.length === job.commands.filter(cmd => cmd.type === 'test').length
22
+ testActs.length === report.acts.filter(act => act.type === 'test').length
28
23
  && testActs.every(testAct => testAct.result && testAct.result.failureCount !== undefined)
29
24
  ) {
30
25
  console.log('Success: Reports have been correctly populated');
File without changes
@@ -0,0 +1,3 @@
1
+ # jobs
2
+
3
+ Directory watched by executor `watchDir`.
package/watch.js CHANGED
@@ -19,7 +19,6 @@ const client = require(protocol);
19
19
  const jobURL = process.env.JOB_URL;
20
20
  const agent = process.env.AGENT;
21
21
  const jobDir = process.env.JOBDIR;
22
- const doneDir = process.env.DONEDIR;
23
22
  const reportURL = process.env.REPORT_URL;
24
23
  const reportDir = process.env.REPORTDIR;
25
24
 
@@ -28,11 +27,11 @@ const reportDir = process.env.REPORTDIR;
28
27
  // Checks for a directory job.
29
28
  const checkDirJob = async () => {
30
29
  try {
31
- const jobDirFileNames = await fs.readdir(jobDir);
32
- const jobFileNames = jobDirFileNames.filter(fileName => fileName.endsWith('.json'));
30
+ const toDoDirFileNames = await fs.readdir(`${jobDir}/todo`);
31
+ const jobFileNames = toDoDirFileNames.filter(fileName => fileName.endsWith('.json'));
33
32
  if (jobFileNames.length) {
34
33
  console.log('Directory job found');
35
- const jobJSON = await fs.readFile(`${jobDir}/${jobFileNames[0]}`, 'utf8');
34
+ const jobJSON = await fs.readFile(`${jobDir}/todo/${jobFileNames[0]}`, 'utf8');
36
35
  try {
37
36
  const job = JSON.parse(jobJSON, null, 2);
38
37
  return job;
@@ -89,13 +88,14 @@ const checkNetJob = async () => {
89
88
  };
90
89
  // Writes a directory report.
91
90
  const writeDirReport = async report => {
92
- const jobID = report && report.job && report.job.id;
91
+ const jobID = report && report.id;
93
92
  if (jobID) {
94
93
  try {
95
94
  const reportJSON = JSON.stringify(report, null, 2);
96
95
  const reportName = `${jobID}.json`;
97
- await fs.writeFile(`${reportDir}/${reportName}`, reportJSON);
98
- console.log(`Report ${reportName} saved`);
96
+ const rawDir = `${reportDir}/raw`;
97
+ await fs.writeFile(`${rawDir}/${reportName}`, reportJSON);
98
+ console.log(`Report ${reportName} saved in ${rawDir}`);
99
99
  }
100
100
  catch(error) {
101
101
  console.log(`ERROR: Failed to write report (${error.message})`);
@@ -129,7 +129,7 @@ const writeNetReport = async report => {
129
129
  }
130
130
  });
131
131
  });
132
- report.agent = agent;
132
+ report.jobData.agent = agent;
133
133
  request.on('error', error => {
134
134
  console.log(`ERROR submitting job report (${error.message})`);
135
135
  resolve({
@@ -140,7 +140,7 @@ const writeNetReport = async report => {
140
140
  // Send the report to the server.
141
141
  request.write(JSON.stringify(report, null, 2));
142
142
  request.end();
143
- console.log(`Report ${report.job.id} submitted`);
143
+ console.log(`Report ${report.id} submitted`);
144
144
  });
145
145
  // Return the server response.
146
146
  return ack;
@@ -148,8 +148,8 @@ const writeNetReport = async report => {
148
148
  // Archives a job.
149
149
  const archiveJob = async job => {
150
150
  const jobJSON = JSON.stringify(job, null, 2);
151
- await fs.writeFile(`${doneDir}/${job.id}.json`, jobJSON);
152
- await fs.rm(`${jobDir}/${job.id}.json`);
151
+ await fs.writeFile(`${jobDir}/done/${job.id}.json`, jobJSON);
152
+ await fs.rm(`${jobDir}/todo/${job.id}.json`);
153
153
  };
154
154
  // Waits.
155
155
  const wait = ms => {
@@ -159,29 +159,23 @@ const wait = ms => {
159
159
  }, ms);
160
160
  });
161
161
  };
162
- // Runs a job and returns the page.
162
+ // Runs a job.
163
163
  const runJob = async (job, isDirWatch) => {
164
164
  // If the job has an ID:
165
165
  const {id} = job;
166
166
  if (id) {
167
167
  try {
168
- // Initialize a report.
169
- const report = {
170
- job,
171
- acts: [],
172
- jobData: {}
173
- };
174
168
  // Run the job, adding to the report.
175
- await doJob(report);
169
+ await doJob(job);
176
170
  // If a directory was watched:
177
171
  if (isDirWatch) {
178
172
  // Save the report.
179
- await writeDirReport(report);
173
+ await writeDirReport(job);
180
174
  }
181
175
  // Otherwise, i.e. if the network was watched:
182
176
  else {
183
177
  // Send the report to the server.
184
- const ack = await writeNetReport(report);
178
+ const ack = await writeNetReport(job);
185
179
  if (ack.error) {
186
180
  console.log(JSON.stringify(ack, null, 2));
187
181
  }
@@ -222,7 +216,7 @@ exports.cycle = async (isDirWatch, isForever, interval) => {
222
216
  if (job.id) {
223
217
  // Run it and save a report.
224
218
  console.log(`Running job ${job.id}`);
225
- await runJob(job, isDirWatch);
219
+ await runJob(JSON.parse(JSON.stringify(job)), isDirWatch);
226
220
  console.log(`Job ${job.id} finished`);
227
221
  // If a directory was watched:
228
222
  if (isDirWatch) {
package/high.js DELETED
@@ -1,60 +0,0 @@
1
- /*
2
- high.js
3
- Invokes Testaro with the high-level method.
4
- Usage example: node high tp25
5
- */
6
-
7
- // ########## IMPORTS
8
-
9
- // Module to keep secrets.
10
- require('dotenv').config();
11
- // Module to read and write files.
12
- const fs = require('fs/promises');
13
- // Module to run jobs and report results.
14
- const {doJob} = require('./run');
15
-
16
- // ########## CONSTANTS
17
-
18
- const jobDir = process.env.JOBDIR;
19
- const reportDir = process.env.REPORTDIR;
20
-
21
- // ########## VARIABLES
22
-
23
- // Set 5 minutes as a default time limit.
24
- let timeLimit = 300;
25
-
26
- // ########## FUNCTIONS
27
-
28
- // Performs a file-based job and writes a report file.
29
- exports.runJob = async jobID => {
30
- try {
31
- // Get the job.
32
- const jobJSON = await fs.readFile(`${jobDir}/${jobID}.json`, 'utf8');
33
- const job = JSON.parse(jobJSON);
34
- // If the job has no time limit, give it the default one.
35
- if (! job.timeLimit) {
36
- job.timeLimit = timeLimit;
37
- }
38
- // Initialize a report for the job.
39
- const report = {
40
- job,
41
- acts: [],
42
- jobData: {}
43
- };
44
- // If the initialized report is valid, run the job, adding the results to the report.
45
- const done = await doJob(report);
46
- if (done) {
47
- const reportJSON = JSON.stringify(report, null, 2);
48
- await fs.writeFile(`${reportDir}/${jobID}.json`, reportJSON);
49
- console.log(`Report ${jobID}.json recorded in ${process.env.REPORTDIR}`);
50
- return true;
51
- }
52
- else {
53
- return false;
54
- }
55
- }
56
- catch(error) {
57
- console.log(`ERROR running job (${error.message})\n${error.stack}`);
58
- return false;
59
- }
60
- };
@@ -1,52 +0,0 @@
1
- // high.js
2
- // Validator for high-level invocation of Testaro.
3
-
4
- // ########## IMPORTS
5
-
6
- const fs = require('fs/promises');
7
-
8
- // ########## CONSTANTS
9
-
10
- const projectRoot = `${__dirname}/../..`;
11
- process.env.JOBDIR = `${projectRoot}/validation/jobs`;
12
- process.env.REPORTDIR = `${projectRoot}/temp`;
13
- const reportDir = process.env.REPORTDIR;
14
- const jobID = '00000-simple-example';
15
-
16
- // ########## OPERATION
17
-
18
- // Run the simple job and write a report.
19
- const {runJob} = require(`${projectRoot}/high`);
20
- runJob(jobID)
21
- .then(
22
- // When the report has been written:
23
- async () => {
24
- try {
25
- // Check it against expectations.
26
- const reportJSON = await fs.readFile(`${reportDir}/${jobID}.json`, 'utf8');
27
- const report = JSON.parse(reportJSON);
28
- const {job, acts, jobData} = report;
29
- if (! job) {
30
- console.log('Failure: Report omits job');
31
- }
32
- else if (acts.length !== 3) {
33
- console.log('Failure: Counts of acts is not 3');
34
- }
35
- else if (! jobData) {
36
- console.log('Failure: Report omits jobData');
37
- }
38
- else if (jobData.endTime < jobData.startTime) {
39
- console.log('Failure: End time precedes start time');
40
- }
41
- else {
42
- console.log(`Success (report is in temp/${jobID}.json)`);
43
- }
44
- }
45
- catch(error) {
46
- console.log(`ERROR: ${error.message}`);
47
- }
48
- },
49
- error => {
50
- console.log(`ERROR running job (${error.message})`);
51
- }
52
- );