Skip to content

Conversation

juj
Copy link
Collaborator

@juj juj commented Aug 21, 2025

Fix wasm2js.test_memorygrowth, wasm2js.test_memorygrowth_2, wasm2js0.test_minimal_runtime_memorygrowth

self.do_runf(src, '*pre: hello,4.955*\n*hello,4.955*\n*hello,4.955*')
if self.is_wasm2js() and '-O0' in self.cflags:
expect = '*pre: hello,4.955*\nWarning: Enlarging memory arrays, this is not fast! 16908288,20316160\n*hello,4.955*\n*hello,4.955*'
else:
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps it would be simpler to add a helper function self.remove_growth_warning(output) which would remove the warning, and call it from these places?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, the output is handled internally inside self.do_runf(src, expect), the test code here doesn't get access to it, but only feeds the expectation. So the function self.do_runf(src, expect) would have to be broken apart for that.

Or did you mean that the remove_growth_warning() function would be called on these expectation strings?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I thought do_runf had a way to filter strings. We used to, but I guess it was removed ("nicerizer function"). Though there is a regex param, but using it on these strings could be annoying...

My concern is that the hardcoded 16908288,20316160 figures will get out of date and need annoying updates, so I think it is worth finding a way to avoid that.

One way might be to avoid using do_runf here, and call self.build then run and compare manually.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you want to do the assertion checking outside of do_runf i think you can just grab the output from the return value:

output = self.do_runf(...)
output = .. filter output ..
self.assertContained(expected, output)

It not has nice a doing it in single do_runf call, but it should work.

Alternatively we could find a way to split the Warning output (stderr) from the actual test output (stdout). Perhaps a stdout_only, param or something like that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i think you can just

Thanks, super useful. Didn't realize that the test would skip asserting and return output like this. Refactored to use this format, how does this look?

expect = '*pre: hello,4.955*\n*hello,4.955*\n*hello,4.955*'
output = self.do_runf(src)
output = self.remove_growth_warning(output)
self.assertContained(expect, output)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Maybe just inline the expect here and below?

lgtm either way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok

@juj juj enabled auto-merge (squash) August 26, 2025 07:49
@juj juj disabled auto-merge August 26, 2025 09:28
@juj juj merged commit 84cfc10 into emscripten-core:main Aug 26, 2025
28 of 30 checks passed
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.

3 participants