@@ -1942,15 +1942,15 @@ def end_headers(self):
1942
1942
def do_POST (self ):
1943
1943
urlinfo = urlparse (self .path )
1944
1944
query = parse_qs (urlinfo .query )
1945
- # Mirror behaviour of emrun which is to write POST'd files to dump_out/ by default
1946
1945
if query ['file' ]:
1947
1946
print ('do_POST: got file: %s' % query ['file' ])
1948
- ensure_dir ('dump_out' )
1949
- filename = os .path .join ('dump_out' , query ['file' ][0 ])
1947
+ filename = query ['file' ][0 ]
1950
1948
contentLength = int (self .headers ['Content-Length' ])
1951
1949
create_file (filename , self .rfile .read (contentLength ), binary = True )
1952
1950
self .send_response (200 )
1953
1951
self .end_headers ()
1952
+ else :
1953
+ print (f'do_POST: unexpected POST: { urlinfo .query } ' )
1954
1954
1955
1955
def do_GET (self ):
1956
1956
if self .path == '/run_harness' :
@@ -2237,15 +2237,32 @@ def make_reftest(self, expected, manually_trigger=False):
2237
2237
total += Math.abs(expected[y*width*4 + x*4 + 2] - actual[y*width*4 + x*4 + 2]);
2238
2238
}
2239
2239
}
2240
- var wrong = Math.floor(total / (img.width*img.height*3)); // floor, to allow some margin of error for antialiasing
2241
- // If the main JS file is in a worker, or modularize, then we need to supply our own reporting logic.
2242
- if (typeof reportResultToServer === 'undefined') {
2243
- (() => {
2244
- %s
2245
- reportResultToServer(wrong);
2246
- })();
2240
+ // floor, to allow some margin of error for antialiasing
2241
+ var wrong = Math.floor(total / (img.width*img.height*3));
2242
+
2243
+ function reportResult(result) {
2244
+ // If the main JS file is in a worker, or modularize, then we need to supply our own
2245
+ // reporting logic.
2246
+ if (typeof reportResultToServer === 'undefined') {
2247
+ (() => {
2248
+ %s
2249
+ reportResultToServer(result);
2250
+ })();
2251
+ } else {
2252
+ reportResultToServer(result);
2253
+ }
2254
+ }
2255
+
2256
+ var rebaseline = %s;
2257
+ if (wrong || rebaseline) {
2258
+ // Generate a png of the actual rendered image and send it back
2259
+ // to the server.
2260
+ Module.canvas.toBlob((blob) => {
2261
+ sendFileToServer('actual.png', blob);
2262
+ reportResult(wrong);
2263
+ })
2247
2264
} else {
2248
- reportResultToServer (wrong);
2265
+ reportResult (wrong);
2249
2266
}
2250
2267
};
2251
2268
actualImage.src = actualUrl;
@@ -2256,7 +2273,8 @@ def make_reftest(self, expected, manually_trigger=False):
2256
2273
/** @suppress {uselessCode} */
2257
2274
function setupRefTest() {
2258
2275
// Automatically trigger the reftest?
2259
- if (!%s) {
2276
+ var manuallyTrigger = %s;
2277
+ if (!manuallyTrigger) {
2260
2278
// Yes, automatically
2261
2279
2262
2280
Module['postRun'] = doReftest;
@@ -2293,7 +2311,7 @@ def make_reftest(self, expected, manually_trigger=False):
2293
2311
}
2294
2312
2295
2313
setupRefTest();
2296
- ''' % (reporting , int (manually_trigger )))
2314
+ ''' % (reporting , EMTEST_REBASELINE , int (manually_trigger )))
2297
2315
2298
2316
def compile_btest (self , filename , args , reporting = Reporting .FULL ):
2299
2317
# Inject support code for reporting results. This adds an include a header so testcases can
@@ -2334,7 +2352,12 @@ def reftest(self, filename, reference, reference_slack=0, manual_reference=False
2334
2352
kwargs .setdefault ('args' , [])
2335
2353
kwargs ['args' ] += ['--pre-js' , 'reftest.js' , '-sGL_TESTING' ]
2336
2354
2337
- return self .btest (filename , expected = expected , * args , ** kwargs )
2355
+ try :
2356
+ return self .btest (filename , expected = expected , * args , ** kwargs )
2357
+ finally :
2358
+ if EMTEST_REBASELINE and os .path .exists ('actual.png' ):
2359
+ print (f'overwriting expected image: { reference } ' )
2360
+ self .run_process ('pngcrush -rem gAMA -rem cHRM -rem iCCP -rem sRGB actual.png' .split () + [reference ])
2338
2361
2339
2362
def btest_exit (self , filename , assert_returncode = 0 , * args , ** kwargs ):
2340
2363
"""Special case of `btest` that reports its result solely via exiting
0 commit comments