Merge pull request #2940 from brendandahl/ref-fixes

Use relative paths for ref images and copy refs.
This commit is contained in:
Brendan Dahl 2013-03-13 11:22:44 -07:00
commit 4fa4f109bd
2 changed files with 23 additions and 7 deletions

View File

@ -110,6 +110,7 @@ var gMagZoom = 16; // size of the zoomed in pixels
var gImage1Data; // ImageData object for the reference image
var gImage2Data; // ImageData object for the test output image
var gFlashingPixels = []; // array of <path> objects that should be flashed due to pixel color mismatch
var gPath = ''; // path taken from #web= and prepended to ref/snp urls
function ID(id) {
if (!(id in gIDCache))
@ -190,6 +191,11 @@ function show_phase(phaseid) {
}
function loadFromWeb(url) {
var lastSlash = url.lastIndexOf('/');
if (lastSlash) {
gPath = url.substring(0, lastSlash + 1);
}
var r = new XMLHttpRequest();
r.open("GET", url);
r.onreadystatechange = function() {
@ -344,7 +350,7 @@ function get_image_data(src, whenReady) {
whenReady(ctx.getImageData(0, 0, 800, 1000));
};
img.src = src;
img.src = gPath + src;
}
function show_images(i) {
@ -356,17 +362,17 @@ function show_images(i) {
ID("diffrect").style.display = "none";
ID("imgcontrols").reset();
ID("image1").setAttributeNS(XLINK_NS, "xlink:href", item.images[0]);
ID("image1").setAttributeNS(XLINK_NS, "xlink:href", gPath + item.images[0]);
// Making the href be #image1 doesn't seem to work
ID("feimage1").setAttributeNS(XLINK_NS, "xlink:href", item.images[0]);
ID("feimage1").setAttributeNS(XLINK_NS, "xlink:href", gPath + item.images[0]);
if (item.images.length == 1) {
ID("imgcontrols").style.display = "none";
} else {
ID("imgcontrols").style.display = "";
ID("image2").setAttributeNS(XLINK_NS, "xlink:href", item.images[1]);
ID("image2").setAttributeNS(XLINK_NS, "xlink:href", gPath + item.images[1]);
// Making the href be #image2 doesn't seem to work
ID("feimage2").setAttributeNS(XLINK_NS, "xlink:href", item.images[1]);
ID("feimage2").setAttributeNS(XLINK_NS, "xlink:href", gPath + item.images[1]);
}
cell.style.display = "";

View File

@ -694,12 +694,17 @@ def checkEq(task, results, browser, masterMode):
handle.write(snapshot)
handle.close()
refSnapshotPath = os.path.join(testSnapshotDir, str(page) + '_ref.png')
handle = open(refSnapshotPath, 'wb')
handle.write(ref)
handle.close()
# NB: this follows the format of Mozilla reftest
# output so that we can reuse its reftest-analyzer
# script
eqLog.write('REFTEST TEST-UNEXPECTED-FAIL | ' + browser +'-'+ taskId +'-page'+ str(page) + ' | image comparison (==)\n')
eqLog.write('REFTEST IMAGE 1 (TEST): ' + '/test/' + testSnapshotPath + '\n')
eqLog.write('REFTEST IMAGE 2 (REFERENCE): ' + '/test/' + path + '\n')
eqLog.write('REFTEST IMAGE 1 (TEST): ' + testSnapshotPath + '\n')
eqLog.write('REFTEST IMAGE 2 (REFERENCE): ' + refSnapshotPath + '\n')
passed = False
State.numEqFailures += 1
@ -793,6 +798,11 @@ def startReftest(browser, options):
print "Completed reftest usage."
def runTests(options, browsers):
try:
shutil.rmtree(TEST_SNAPSHOTS);
except OSError, e:
if e.errno != 2: # folder doesn't exist
print >>sys.stderr, 'Deleting', dir, 'failed!'
t1 = time.time()
try:
startBrowsers(browsers, options, '/test/test_slave.html')