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

Tests.ex: 'Invalid filename' when adding test modules #1479

Open
petermm opened this issue Jan 19, 2025 · 8 comments
Open

Tests.ex: 'Invalid filename' when adding test modules #1479

petermm opened this issue Jan 19, 2025 · 8 comments

Comments

@petermm
Copy link
Contributor

petermm commented Jan 19, 2025

For more elixir testing we need to use various test modules in Tests.ex.

TIL sub/nested modules included in Tests.ex, doesn't work due using elixirc for compilation.

In #1476 I include them in exavmlib (they will go in own testexavmlib, but to minimise moving parts while resolving this issue, they are in exavmlib).

This leads to these warnings: (failing to parse filename?)

Invalid filename: expected filename data (27008 bytes).
Invalid filename: expected filename data (27008 bytes).
Invalid filename: expected filename data (27008 bytes).
Invalid filename: expected filename data (18719 bytes).

Tests/runtime still works, however when crashing with a stacktrace, it will segfault due to filenames having been set to NULL.

Any guidance?

@UncleGrumpy
Copy link
Collaborator

UncleGrumpy commented Jan 19, 2025

If you look in tests/libs directory there are tests bundles to test each library. I would add a exavmlib directory there, and pack the tests with the atomvmlib libraries. Then just make sure the CMakeLists.txt packs the standard + exavmlib with the test, see here:

pack_test(test_eavmlib eavmlib estdlib etest)

@petermm
Copy link
Contributor Author

petermm commented Jan 19, 2025

Yeah, but this is already done here for Tests.ex (it's the initial elixir testing) https://github.com/atomvm/AtomVM/blob/a00098a09055ef5751e409bedc18381a6f7f66e4/tests/libs/exavmlib/CMakeLists.txt

but something isn't quite right.. hopefully some oversight by me..

@UncleGrumpy
Copy link
Collaborator

UncleGrumpy commented Jan 20, 2025

Yeah, but this is already done here for Tests.ex (it's the initial elixir testing) https://github.com/atomvm/AtomVM/blob/a00098a09055ef5751e409bedc18381a6f7f66e4/tests/libs/exavmlib/CMakeLists.txt

but something isn't quite right.. hopefully some oversight by me..

You should be adding your test modules here in this file too, like the eavmlib tests:
https://github.com/atomvm/AtomVM/blob/a00098a09055ef5751e409bedc18381a6f7f66e4/tests/libs/eavmlib/CMakeLists.txt#L25..34
instead of including them from some other project called Tests...

@UncleGrumpy
Copy link
Collaborator

No, never mind that previous comment, I didn't realize all of the tests were in a single module called Tests.

@UncleGrumpy
Copy link
Collaborator

UncleGrumpy commented Jan 20, 2025

So did you try putting GenServerTest.CustomStack.ex, and GenServerTest.Stack.ex into tests/libs/examvlib/ and adding them to a packed archive with Tests.ex (like eavmlib does with the set() and pack_archive()), and add both the MODULE:start() to Tests.ex?

@petermm
Copy link
Contributor Author

petermm commented Jan 20, 2025

I've tried it all, but it does seem like I should try and port packtest macro to the elixir side and try to replicate that tests.erl pattern in Tests.ex.

@UncleGrumpy
Copy link
Collaborator

UncleGrumpy commented Jan 20, 2025

I've tried it all, but it does seem like I should try and port packtest macro to the elixir side and try to replicate that tests.erl pattern in Tests.ex.

Yes! I believe this is it. I started comparing the differences and this it the same conclusion I came to. That macro packs together all of the test modules into a single test application, which is what we need to happen for extra Elixir test modules, otherwise it will only find the Tests module itself.

@petermm
Copy link
Contributor Author

petermm commented Jan 21, 2025

the bug is in the nested/sub modules, eg. GenServerTest.CustomStack will give the error, but identical module/code within GenServerTest will give no error.

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

No branches or pull requests

2 participants