diff --git a/test/reftest.js b/test/reftest.js index f93146a91e9a0..9f2b29dc246de 100644 --- a/test/reftest.js +++ b/test/reftest.js @@ -65,16 +65,18 @@ function doReftest() { } } // floor, to allow some margin of error for antialiasing - var wrong = Math.floor(total / (img.width*img.height*3)); + var delta = Math.floor(total / (img.width*img.height*3)); + console.log(`image delta = ${delta}`); + var wrong = delta > reftestSlack; if (wrong || reftestRebaseline) { // Generate a png of the actual rendered image and send it back // to the server. Module['canvas'].toBlob((blob) => { sendFileToServer('actual.png', blob); - reportResultToServer(wrong); + reportResultToServer(wrong ? `mismatch:${delta}` : 'match'); }) } else { - reportResultToServer(wrong); + reportResultToServer('match'); } }; actualImage.src = actualUrl; diff --git a/test/test_browser.py b/test/test_browser.py index 80566e324767a..4f94edb780890 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -264,11 +264,12 @@ def post_manual_reftest(self): ''') create_file('test.html', html) - def make_reftest(self, expected): + def make_reftest(self, expected, reference_slack=0): # make sure the pngs used here have no color correction, using e.g. # pngcrush -rem gAMA -rem cHRM -rem iCCP -rem sRGB infile outfile shutil.copy(expected, 'expected.png') create_file('reftest.js', f''' + const reftestSlack = {reference_slack}; const reftestRebaseline = {common.EMTEST_REBASELINE}; ''' + read_file(test_file('reftest.js'))) @@ -277,8 +278,7 @@ def reftest(self, filename, reference, reference_slack=0, *args, **kwargs): """ reference = find_browser_test_file(reference) assert 'expected' not in kwargs - expected = [str(i) for i in range(reference_slack + 1)] - self.make_reftest(reference) + self.make_reftest(reference, reference_slack) if '--proxy-to-worker' in self.emcc_args: assert 'post_build' not in kwargs kwargs['post_build'] = self.post_manual_reftest @@ -289,7 +289,7 @@ def reftest(self, filename, reference, reference_slack=0, *args, **kwargs): kwargs['emcc_args'] += ['--pre-js', 'reftest.js', '-sGL_TESTING'] try: - return self.btest(filename, expected=expected, *args, **kwargs) + return self.btest(filename, expected='match', *args, **kwargs) finally: if common.EMTEST_REBASELINE and os.path.exists('actual.png'): print(f'overwriting expected image: {reference}')