-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
executable file
·50 lines (43 loc) · 1.17 KB
/
test.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
#!/usr/bin/env node
/*global setTimeout*/
var DotReporter = require('./lib/DotReporter').DotReporter,
config = {
start: 'white',
end: 'green',
err: 'red',
foo: 'brown',
bar: 'blue',
hat: 'cyan'
},
configKeys = Object.keys(config).filter(function (key) {
return key !== 'start';
}),
d = new DotReporter(config),
ids = [],
started = [];
for (var i = 0; i < 180; i += 1) {
ids.push(i);
}
function report() {
var id = ids.pop();
if (id) {
d.taskStart(id);
started.push(id);
setTimeout(function () {
report();
setTimeout(function () {
do {
var idx = Math.floor(Math.random() * started.length),
num = started[idx];
if (num) {
d.taskEnd(id, configKeys[Math.floor(Math.random() * configKeys.length)]);
delete started[idx];
break;
}
} while (1);
}, 2000 * Math.random() + 1000);
}, 100);
}
}
process.stderr.write('\r\n');
report();