forked from FredrikNoren/ungit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
teststabilitytester.js
44 lines (40 loc) · 1.34 KB
/
teststabilitytester.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
#!/usr/bin/env node
// This repeatedly runs the click and unit tests to verify their stability
var childProcess = require('child_process');
var moment = require('moment');
var runClickTest = function(callback) {
var child =
child.on('exit', function(code) {
callback(null, code != 0);
});
}
var count = 0;
var clickTestErrors = 0;
var unitTestErrors = 0;
var startTime = Date.now();
var run = function() {
var testTime = Date.now();
count++;
console.log('Round ' + count + '...');
var clickTestChild = childProcess.exec('grunt clicktest', function(err, stdout, stderr) {
if (err) {
clickTestErrors++;
console.log(stdout);
console.log(stderr);
console.log('Clicktest failed!');
}
childProcess.exec('grunt unittest', function(err, stdout, stderr) {
if (err) {
unitTestErrors++;
console.log(stdout);
console.log(stderr);
console.log('Unittest failed!');
}
console.log(count + ' test run, ' + clickTestErrors + ' clicktest errors (' + Math.floor(100*clickTestErrors/count) + '%), ' +
unitTestErrors + ' unittest errors (' + Math.floor(100*unitTestErrors/count) + '%) ' +
'(this round: ' + moment.duration(Date.now() - testTime).asSeconds() + 'sec, total: ' + moment.duration(Date.now() - startTime).humanize() + ')');
run();
});
});
}
run();