-
Notifications
You must be signed in to change notification settings - Fork 166
Expand file tree
/
Copy pathtest.js
More file actions
28 lines (22 loc) · 792 Bytes
/
test.js
File metadata and controls
28 lines (22 loc) · 792 Bytes
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
var fs = require('fs'),
path = require('path');
var testDir = __dirname+'/img-test/',
refDir = __dirname+'/img-ref/';
if (!fs.existsSync(testDir)) {
console.log('! regression warning: img-test/ dir does not exist. creating it...')
fs.mkdirSync(testDir);
}
exports.regression = function(name, pixmap, callback) {
callback();
pixmap.save(testDir+name+'.png');
// Can't compare if refs don't exist
if (!fs.existsSync(refDir+name+'.png')) {
console.log('! regression warning: could not find reference file for test:', name)
return;
}
var testBuf = fs.readFileSync(testDir+name+'.png');
var refBuf = fs.readFileSync(refDir+name+'.png');
if (testBuf.toString() !== refBuf.toString()) {
console.log('!!! image regression in test:', name);
}
}