testilo 2.0.2 → 3.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/README.md +14 -77
- package/package.json +3 -4
- package/procs/score/tsp09.js +565 -0
- package/score.js +33 -0
- package/scoring/correlation.js +76 -0
- package/scoring/correlations.json +327 -0
- package/scoring/data.json +26021 -0
- package/scoring/dupCounts.js +39 -0
- package/scoring/dupCounts.json +112 -0
- package/scoring/duplications.json +253 -0
- package/scoring/issues.json +304 -0
- package/scoring/packageData.js +171 -0
- package/scoring/packageIssues.js +34 -0
- package/scoring/packageRules/aatt.js +543 -0
- package/scoring/rulesetData.json +15 -0
- package/aceconfig.js +0 -6
- package/index.js +0 -88
package/index.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
index.js
|
|
3
|
-
Testilo main script.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// ########## IMPORTS
|
|
7
|
-
|
|
8
|
-
// Module to perform tests.
|
|
9
|
-
const {handleRequest} = require('testaro');
|
|
10
|
-
const fs = require('fs').promises;
|
|
11
|
-
require('dotenv').config();
|
|
12
|
-
|
|
13
|
-
// ########## FUNCTIONS
|
|
14
|
-
|
|
15
|
-
// Converts a script to a batch-based array of scripts.
|
|
16
|
-
const batchify = (script, batch, timeStamp) => {
|
|
17
|
-
const {hosts} = batch;
|
|
18
|
-
const specs = hosts.map(host => {
|
|
19
|
-
const newScript = JSON.parse(JSON.stringify(script));
|
|
20
|
-
newScript.commands.forEach(command => {
|
|
21
|
-
if (command.type === 'url') {
|
|
22
|
-
command.which = host.which;
|
|
23
|
-
command.what = host.what;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
const spec = {
|
|
27
|
-
id: `${timeStamp}-${host.id}`,
|
|
28
|
-
script: newScript
|
|
29
|
-
};
|
|
30
|
-
return spec;
|
|
31
|
-
});
|
|
32
|
-
return specs;
|
|
33
|
-
};
|
|
34
|
-
// Calls Testaro.
|
|
35
|
-
const callTestaro = async (id, script) => {
|
|
36
|
-
const report = {
|
|
37
|
-
id,
|
|
38
|
-
log: [],
|
|
39
|
-
script,
|
|
40
|
-
acts: []
|
|
41
|
-
};
|
|
42
|
-
await handleRequest(report);
|
|
43
|
-
const reportJSON = JSON.stringify(report, null, 2);
|
|
44
|
-
await fs.writeFile(`reports/${id}.json`, reportJSON);
|
|
45
|
-
};
|
|
46
|
-
// Runs a job.
|
|
47
|
-
const run = async () => {
|
|
48
|
-
const scriptID = process.argv[2];
|
|
49
|
-
const batchName = process.argv[3];
|
|
50
|
-
if (scriptID) {
|
|
51
|
-
try {
|
|
52
|
-
const scriptJSON = await fs.readFile(`scripts/${scriptID}.json`, 'utf8');
|
|
53
|
-
const script = JSON.parse(scriptJSON);
|
|
54
|
-
// Identify the start time and a timestamp.
|
|
55
|
-
const timeStamp = Math.floor((Date.now() - Date.UTC(2022, 1)) / 2000).toString(36);
|
|
56
|
-
// If there is a batch:
|
|
57
|
-
let batch = null;
|
|
58
|
-
if (batchName) {
|
|
59
|
-
// Convert the script to a batch-based set of scripts.
|
|
60
|
-
const batchJSON = await fs.readFile(`batches/${batchName}.json`, 'utf8');
|
|
61
|
-
batch = JSON.parse(batchJSON);
|
|
62
|
-
const specs = batchify(script, batch, timeStamp);
|
|
63
|
-
// For each script:
|
|
64
|
-
while (specs.length) {
|
|
65
|
-
const spec = specs.shift();
|
|
66
|
-
const {id, script} = spec;
|
|
67
|
-
// Call Testaro on it and save the result with a host-suffixed ID.
|
|
68
|
-
await callTestaro(id, script);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
// Otherwise, i.e. if there is no batch:
|
|
72
|
-
else {
|
|
73
|
-
// Call Testaro on the script and save the result with a timestamp ID.
|
|
74
|
-
await callTestaro(timeStamp, script);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
catch(error) {
|
|
78
|
-
console.log(`ERROR: ${error.message}\n${error.stack}`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
console.log('ERROR: no script specified');
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// ########## OPERATION
|
|
87
|
-
|
|
88
|
-
run();
|