-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun-all.js
93 lines (84 loc) · 3.35 KB
/
run-all.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const shell = require('shelljs');
const fs = require('fs');
const glob = require('glob');
function runAll(project, parameters, benchmarkDir, logSeettings) {
logSeettings = logSeettings || '';
shell.cd(`${benchmarkDir}/${project}`);
let tc = JSON.parse(fs.readFileSync(`nr-passing-tcs-4-control.json.log`, 'utf8'));
let consideredTests = tc.filter(t => t.status && t.status.includes('success'));
let projStats = {
name: project,
consideredTests: consideredTests.length,
testsWithInterleaving: 0,
successfulTests: 0,
failingTests: 0
};
consideredTests.forEach(t => {
console.log('file: ' + t.file);
console.log('title: ' + t.title);
shell.rm('-R', 'log');
let pure_command = `mocha --exit -t 20000 -R spec ${parameters} ${t.file} -f "${sanitize(t.title)}"`;
let command = `noderacer log ${pure_command} ${logSeettings}`;
t.status = [];
try {
let execOut = shell.exec(command, { silent: true });
if (execOut.stdout.includes('0 passing')) {
t.status.push('fail in log');
}
else {
//H-B
glob.sync('log/*/noderacer*.log.json').forEach(hbfile => {
let hb_command = `timeout 30 noderacer hb ${hbfile}`;
let execOut = shell.exec(hb_command, { silent: false });
if (execOut.code === 124) { //timeout
//try with no globals
let hb_command2 = `timeout 60 noderacer hb ${hbfile} --ng`;
let execOut = shell.exec(hb_command2, { silent: false });
if (execOut.code === 124) //timeout
t.status.push('timeout without global');
else {
runControlPhase(t, pure_command, hbfile.replace('.log.json', '.hb.json'), projStats);
}
}
else {
runControlPhase(t, pure_command, hbfile.replace('.log.json', '.hb.json'), projStats);
}
});
}
} catch (error) {
t.status.push('exception launched');
}
});
console.log(`-------------------------------------`);
console.log(projStats);
}
function sanitize(str) {
str = str.replace(/`/g, '\\`');
str = str.replace(/"/g, '\\"');
str = str.replace(/\$/g, '\\$');
return str;
}
function runControlPhase(t, command, hbfile, projStats) {
// check for interleavings
let susp_command = `noderacer susp ${hbfile} -m cmio`;
let execOut = shell.exec(susp_command, { silent: false });
if (execOut.stdout.includes('CMIO: 0.00')) {
t.status.push('no interleaving');
}
else {
projStats.testsWithInterleaving++;
let control_command = `noderacer control -s random -r 100 -h ${hbfile} ${command}`;
let execOut = shell.exec(control_command, { silent: false });
if (execOut.stdout.includes('0 passing')) {
projStats.failingTests++;
t.status.push('fail TC');
t.fails = execOut.stdout.match(/0 passing/g).length;
}
else {
projStats.successfulTests++;
t.status.push('success');
t.fails = 0;
}
}
}
module.exports = runAll;