Created
September 19, 2011 04:19
-
-
Save jcjc/1225954 to your computer and use it in GitHub Desktop.
Layout testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var runTests = function(callback) { | |
var testsFinishedCount = 0; | |
var testFailures = []; | |
var layouts = config.SETTINGS.layouts; | |
var processNextLayout = function() { | |
var layout = layouts.shift(); | |
if (layout) { | |
var rasterizeCmd = RASTERIZE_CMD_TEMPLATE({ | |
url: buildUrl(layout.url), | |
path: config.SETTINGS.tmpPath + layout.page + '.png' | |
}); | |
exec(rasterizeCmd, function(output) { | |
var diffCmd = DIFF_CMD_TEMPLATE({ | |
file1: config.SETTINGS.baselinePath + layout.page + '.png', | |
file2: config.SETTINGS.tmpPath + layout.page + '.png', | |
}); | |
exec(diffCmd, function(error, stdout, stderr) { | |
var result = parseDiff(stdout); | |
var failed = result && result.diffAmount > config.SETTINGS.tolerancePercent; | |
if (failed) { | |
testFailures.push({ | |
page: layout.page, | |
diffAmount: result.diffAmount | |
}); | |
} | |
testsFinishedCount++; | |
processNextLayout(); | |
}); | |
}); | |
} else { | |
callback(testsFinishedCount, testFailures); | |
} | |
}; | |
processNextLayout(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment