-
Notifications
You must be signed in to change notification settings - Fork 615
/
index.js
62 lines (48 loc) · 1.66 KB
/
index.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
// gm - Copyright Aaron Heckmann <aaron.heckmann+github@gmail.com> (MIT Licensed)
var dir = __dirname + '/../examples/imgs';
var gm = require('../');
var assert = require('assert');
var gleak = require('gleak')();
var fs = require('fs');
var only = process.argv.slice(2);
gm.integration = !! ~process.argv.indexOf('--integration');
if (gm.integration) only.shift();
var files = fs.readdirSync(__dirname).filter(filter);
var pending, total = pending = files.length * 2;
function filter (file) {
if (!/\.js$/.test(file)) return false;
if ('index.js' === file) return false;
if (only.length && !~only.indexOf(file)) return false;
var filename = __dirname + '/' + file;
if (!fs.statSync(filename).isFile()) return false;
return true;
}
function test (imagemagick) {
if (imagemagick)
return gm(dir + '/original.jpg').options({ imageMagick: true });
return gm(dir + '/original.jpg');
}
function finish (filename) {
return function (err) {
if (err) throw err;
--pending;
process.stdout.write('\033[2K');
process.stdout.write('\033[0G');
process.stdout.write('pending ' + pending);
if (pending) return;
process.stdout.write('\033[?25h');
process.stdout.write('\033[2K');
process.stdout.write('\033[0G');
var leaks = gleak.detect();
assert.equal(0, leaks.length, "global leaks detected: " + leaks);
console.error("\n\u001B[32mAll tests passed\u001B[0m");
}
}
process.stdout.write('\033[?25l');
files.forEach(function (file) {
var filename = __dirname + '/' + file;
// gm tests
require(filename)(test(), dir, finish(filename), gm);
// imagemagick tests
require(filename)(test(true), dir, finish(filename), gm);
});