Skip to content

Commit

Permalink
[test] Pass filename explicitly to compile_btest helper. NFC
Browse files Browse the repository at this point in the history
This allows us to use `compiler_for` to determine whether to run
`EMCC` or `EMXX` appropriately.
  • Loading branch information
sbc100 committed Jan 18, 2024
1 parent 946c850 commit 732ac8d
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 69 deletions.
21 changes: 12 additions & 9 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2106,24 +2106,27 @@ def reftest(self, expected, manually_trigger=False):
setupRefTest();
''' % (reporting, basename, int(manually_trigger)))

def compile_btest(self, args, reporting=Reporting.FULL):
def compile_btest(self, filename, args, reporting=Reporting.FULL):
# Inject support code for reporting results. This adds an include a header so testcases can
# use REPORT_RESULT, and also adds a cpp file to be compiled alongside the testcase, which
# contains the implementation of REPORT_RESULT (we can't just include that implementation in
# the header as there may be multiple files being compiled here).
if reporting != Reporting.NONE:
# For basic reporting we inject JS helper funtions to report result back to server.
args += ['-DEMTEST_PORT_NUMBER=%d' % self.port,
'--pre-js', test_file('browser_reporting.js')]
args += ['--pre-js', test_file('browser_reporting.js'),
'-include', test_file('report_result.h')]
if reporting == Reporting.FULL:
# If C reporting (i.e. REPORT_RESULT macro) is required
# also compile in report_result.c and forice-include report_result.h
args += ['-I' + TEST_ROOT,
'-include', test_file('report_result.h'),
test_file('report_result.c')]
self.run_process([EMCC, '-c', '-I' + TEST_ROOT,
'-DEMTEST_PORT_NUMBER=%d' % self.port,
test_file('report_result.c')] + self.get_emcc_args())
args.append('report_result.o')
if EMTEST_BROWSER == 'node':
args.append('-DEMTEST_NODE')
self.run_process([EMCC] + self.get_emcc_args() + args)
if not os.path.exists(filename):
filename = test_file(filename)
self.run_process([compiler_for(filename), filename] + self.get_emcc_args() + args)

def btest_exit(self, filename, assert_returncode=0, *args, **kwargs):
"""Special case of btest that reports its result solely via exiting
Expand Down Expand Up @@ -2166,10 +2169,10 @@ def btest(self, filename, expected=None, reference=None,
# manual_reference only makes sense for reference tests
assert manual_reference is None
outfile = output_basename + '.html'
args += [filename, '-o', outfile]
args += ['-o', outfile]
# print('all args:', args)
utils.delete_file(outfile)
self.compile_btest(args, reporting=reporting)
self.compile_btest(filename, args, reporting=reporting)
self.assertExists(outfile)
if post_build:
post_build()
Expand Down

0 comments on commit 732ac8d

Please sign in to comment.