Skip to content

Commit

Permalink
[test] Add reftest helper method for browser tests. NFC
Browse files Browse the repository at this point in the history
This makes it easy distinguish reference tests from other btests.
  • Loading branch information
sbc100 committed Feb 22, 2024
1 parent 5355b8d commit 01aa990
Show file tree
Hide file tree
Showing 2 changed files with 184 additions and 181 deletions.
13 changes: 10 additions & 3 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2010,7 +2010,7 @@ def run_browser(self, html_file, expected=None, message=None, timeout=None, extr

# @manually_trigger If set, we do not assume we should run the reftest when main() is done.
# Instead, call doReftest() in JS yourself at the right time.
def reftest(self, expected, manually_trigger=False):
def make_reftest(self, expected, manually_trigger=False):
# make sure the pngs used here have no color correction, using e.g.
# pngcrush -rem gAMA -rem cHRM -rem iCCP -rem sRGB infile outfile
basename = os.path.basename(expected)
Expand Down Expand Up @@ -2141,8 +2141,15 @@ def compile_btest(self, filename, args, reporting=Reporting.FULL):
filename = test_file(filename)
self.run_process([compiler_for(filename), filename] + self.get_emcc_args() + args)

def reftest(self, filename, reference, *args, **kwargs):
"""Special case of `btest` that uses reference image
"""
assert 'reference' not in kwargs
kwargs['reference'] = reference
return self.btest(filename, *args, **kwargs)

def btest_exit(self, filename, assert_returncode=0, *args, **kwargs):
"""Special case of btest that reports its result solely via exiting
"""Special case of `btest` that reports its result solely via exiting
with a given result code.
In this case we set EXIT_RUNTIME and we don't need to provide the
Expand Down Expand Up @@ -2175,7 +2182,7 @@ def btest(self, filename, expected=None, reference=None,
if reference:
self.reference = reference
expected = [str(i) for i in range(0, reference_slack + 1)]
self.reftest(test_file(reference), manually_trigger=manually_trigger_reftest)
self.make_reftest(test_file(reference), manually_trigger=manually_trigger_reftest)
if not manual_reference:
args += ['--pre-js', 'reftest.js', '-sGL_TESTING']
else:
Expand Down
Loading

0 comments on commit 01aa990

Please sign in to comment.