Skip to content
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

Add support for --preload-file and under node #11785

Merged
merged 5 commits into from Jun 3, 2021
Merged

Add support for --preload-file and under node #11785

merged 5 commits into from Jun 3, 2021

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Aug 1, 2020

I did this to help me to test the pre-load plugins which don't run
with --embed-file. Is it worth landing this for testing reasons
alone. Should the preload plugins work under node?

I did this to all me to test the pre-load plugins which don't run
with `--embed-file`.  Is it worth landing this for testing reasons
alone.  Shoudl the preload plugins work under node?
@sbc100 sbc100 requested a review from kripken August 1, 2020 06:35
@sbc100
Copy link
Collaborator Author

sbc100 commented Aug 1, 2020

Is this useful?

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

Nice, looks pretty simple.

lgtm with a test. There may also be docs that need updating.

@kripken
Copy link
Member

kripken commented Aug 3, 2020

I think it's useful in that it removes a difference between web and non-web.

@sbc100
Copy link
Collaborator Author

sbc100 commented Sep 15, 2020

Ok I'll try to get his landded then since it seems it might be useful outside of testing too.

@fs-eire
Copy link
Contributor

fs-eire commented Mar 4, 2021

Is there any chance that we can merge this change recently? It's quite useful feature.

Base automatically changed from master to main March 8, 2021 23:49
@fs-eire
Copy link
Contributor

fs-eire commented May 30, 2021

@sbc100 @kripken any plan to make this change official? we keep updating our patches to file_packager.py when upgrade version of emscripten, in order to use this feature in node.js for our unittest.

@kripken
Copy link
Member

kripken commented Jun 1, 2021

I am very much in favor of landing this. @sbc100 if you don't have time for it, I can pick it up?

@sbc100
Copy link
Collaborator Author

sbc100 commented Jun 1, 2021

I think this probably just needs a test. I don't have time to look at it today so if do please go ahead!

Copy link
Collaborator Author

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

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

thanks!

self.assertContained('|hello from a file wi|', self.run_js('a.out.js'))
self.run_process([EMXX, 'main.cpp'] + args)
# run in node.js to ensure we verify that file preloading works there
result = self.run_js('a.out.js', engine=config.NODE_JS)
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 don't think you need engine=config.NODE_JS here.. its the default for all tests in this file.

Copy link
Member

Choose a reason for hiding this comment

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

This is defending against the default possibly changing in the future. Seems safer to make it explicit in places where it is specifically needed?

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, I think we should come up with a better way to specify node-only tests in the future. Maybe @requires_node or something like that.

errback(err);
} else {
console.log('got data');
console.log(typeof contents.buffer);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Remove these two lines.

@kripken
Copy link
Member

kripken commented Jun 2, 2021

As your own PR I don't think you can approve it @sbc100 but does it look good now after the last changes?

Copy link
Collaborator Author

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -712,6 +710,17 @@ def was_seen(name):

ret += r'''
function fetchRemotePackage(packageName, packageSize, callback, errback) {
if (typeof process === 'object') {
fs = require('fs');
Copy link
Contributor

Choose a reason for hiding this comment

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

@sbc100 Maybe

Suggested change
fs = require('fs');
const fs = require('fs');

? I'm getting a ReferenceError: fs is not defined otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nevermind, I see it was fixed in #14372

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.

None yet

4 participants