Skip to content

Allow setting of CLOSURE_ARGS in ports #24192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ypujante
Copy link
Contributor

This is the implementation that was discussed in #24109

I can update the Changelog in a later commit if the tests pass in CI and this PR is approved.

  • I manually/locally ran other.test_closure_externs to make sure that the changes were not affecting existing code
  • I added a test other.test_closure_args_from_port that piggy back on test_closure_externs to pass the same parameter in the port instead and make sure that these changes actually do what they are supposed to do in the first place.

Hopefully I didn't forget anything. The changes are pretty straightforward in the grand scheme of things.

@ypujante
Copy link
Contributor Author

This is the only test that fails. It doesn't seem to be related to my changes but please let me know if it is.

======================================================================
FAIL [2.055s]: test_sdl_mouse (test_browser.browser_2gb)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/project/test/common.py", line 2353, in run_browser
    self.assertContained(expected, output)
  File "/root/project/test/common.py", line 1652, in assertContained
    self.fail("Expected to find '%s' in '%s', diff:\n\n%s\n%s" % (
  File "/usr/lib/python3.8/unittest/case.py", line 753, in fail
    raise self.failureException(msg)
AssertionError: Expected to find '/report_result?exit:0
' in '//report_result?abort:Assertion failed: abs(m->x-10) <= 1 && abs(m->y-20) <= 1 && abs(m->xrel-10) <= 1 && abs(m->yrel-20) <= 1, at: /root/project/test/browser/test_sdl_mouse.c,32,one
', diff:

--- expected
+++ actual
@@ -1 +1 @@
-/report_result?exit:0
+//report_result?abort:Assertion failed: abs(m->x-10) <= 1 && abs(m->y-20) <= 1 && abs(m->xrel-10) <= 1 && abs(m->yrel-20) <= 1, at: /root/project/test/browser/test_sdl_mouse.c,32,one



During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/project/test/test_browser.py", line 1070, in test_sdl_mouse
    self.btest_exit('test_sdl_mouse.c', emcc_args=['-O2', '--minify=0', '--pre-js', test_file('browser/fake_events.js'), '-lSDL', '-lGL'])
  File "/root/project/test/common.py", line 2404, in btest_exit
    return self.btest(filename, *args, **kwargs)
  File "/root/project/test/common.py", line 2433, in btest
    self.run_browser(outfile + url_suffix, expected=['/report_result?' + e for e in expected], timeout=timeout, extra_tries=extra_tries)
  File "/root/project/test/common.py", line 2358, in run_browser
    return self.run_browser(html_file, expected, message, timeout, extra_tries - 1)
  File "/root/project/test/common.py", line 2360, in run_browser
    raise e
  File "/root/project/test/common.py", line 2353, in run_browser
    self.assertContained(expected, output)
  File "/root/project/test/common.py", line 1652, in assertContained
    self.fail("Expected to find '%s' in '%s', diff:\n\n%s\n%s" % (
AssertionError: Expected to find '/report_result?exit:0
' in '//report_result?abort:Assertion failed: abs(m->x-10) <= 1 && abs(m->y-20) <= 1 && abs(m->xrel-10) <= 1 && abs(m->yrel-20) <= 1, at: /root/project/test/browser/test_sdl_mouse.c,32,one
', diff:

--- expected
+++ actual
@@ -1 +1 @@
-/report_result?exit:0
+//report_result?abort:Assertion failed: abs(m->x-10) <= 1 && abs(m->y-20) <= 1 && abs(m->xrel-10) <= 1 && abs(m->yrel-20) <= 1, at: /root/project/test/browser/test_sdl_mouse.c,32,one

def test_closure_args_from_port(self):
port = test_file('test_closure_args_port.py')
self.run_process([EMCC, test_file('hello_world.c'),
f'--use-port={port}',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does ,...,'--port', test_file('test_closure_args_port.py') .. work here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely. The only purpose of this port is to set the closure args (and obviously test the feature in the process). If this line is commented out the test fails because the closure args are not set on the command line.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is can you avoid the port variable here and do:

self.run_process([EMCC, test_file('hello_world.c'), '--use-port', test_file('test_closure_args_port.py'), ...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e. no need for the f-string

@sbc100 sbc100 changed the title allow using settings.CLOSURE_ARGS in ports Allow setting of CLOSURE_ARGS in ports Apr 27, 2025
@sbc100
Copy link
Collaborator

sbc100 commented Apr 27, 2025

The test_sdl_mouse is a know flake that has been happening for a few days now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants