-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[Question] How do you do automated tests for emscripten builds using googletest? #23543
Comments
Are you using the main function from google test? How does your problem manifest? Does it run the main function but not find any of your tests? Or does the main function not run at all? We do have a test in the test suite that ensure that googletest does work: Lines 14624 to 14634 in 1b46dde
|
Thanks for your speedy response @sbc100 . I've tried both with and without a main function defined. When I include main I try including the following file in the compilation of the MAIN_MODULE https://github.com/jprendes/emscripten-dylink-demo/blob/master/src/main.cpp (this is not currently in my PR mentioned above). No matter what I seem to do I get the same result that is shown in the workflow run I link. To me it looks like it tries to run the tests, and says everything passes, but no tests are actually run. |
I would avoid |
Currently the library we build and link to only works if we build it as a shared library (although there is work being done to hopefully get a static library build in the future) . Is there any way you could suggest I try and link to this shared library without using main_module? I did try and avoid the use of main_module but couldn't find a solution. This is coming trom someone who has only been working with emscripten for a few months now, and still pretty much a novice. |
No, if you have a shared library then you need to build with MAIN_MODULE. Can you write some simple gtests that do not use dynamic linking, just to confirm that that is needed the problem? |
Take a look at https://emscripten.org/docs/api_reference/Filesystem-API.html. Basically emscripten programs run with a virtual filesystem that you can populate in various ways. If you are running on node you can bypass this using |
I assume this is because he program you are testing is itself a compiler and its looking for the |
Regardless its sounds like the problem is no longer related to gtest, but other things, so maybe this issue can be closed? |
Thanks for the information. I'll try and apply your suggestions and see how I get on, opening up another more targeted issue if I cannot fix. I'll close this issue with this message. I'll take the start of the readme from the project to explain what the project I work on is (since I feel it explains it better than I could)
Not sure which will be the best approach in this circumstance, but your comments point me where to look. Again thanks for the help. |
I'm trying to add automated emscripten tests to a project I work on in a PR here compiler-research/CppInterOp#483 . I managed to get Google Test to successfully build and run without error on Emscripten as can be seen here https://github.com/compiler-research/CppInterOp/actions/runs/13006358705/job/36274044251#step:9:279 , but non of the tests appear in the Google Test run. Can someone provide me with a minimal example of how to use Google Test with Emscripten? The only example I have been able to find is here https://github.com/jprendes/emscripten-dylink-demo . It is a few years old and looks out of date since it uses the deprecated compiler setting RUNTIME_LINKED_LIBS . Looking for a more up to date example to guide me.
The text was updated successfully, but these errors were encountered: