M
Modular4mo ago
toasty

Usage of mojo test

Is anyone using mojo test to run their unit tests? I’m trying to use it instead defining a test package that’s executed via mojo run. However, it doesn’t work as described in the docs. If my test directory is not a mojo package, I can’t import my package source code to test it. And -I doesn’t resolve the issue either. I figure I’m just missing something here and was hoping someone else could share their repo as an example.
7 Replies
PhoToN
PhoToN4mo ago
@toasty I faced same problem. Currently, 1) I create a 'tests' folder and add 'test_xyz.mojo' files it. 2) Since '-I' command doesn't seem to be working, I just move the corresponding 'src.mojopkg' file into the tests folder. 3) Now running the 'mojo test tests' command works. I'll update my repo and share it in a bit. Does that answer your question? Feel free to let me know.
toasty
toastyOP4mo ago
Ah gotcha, thanks! I’ll give it a try with the mojopkg file, that’s usually how I test in automation but I didn’t get that far this time. Might just wait until mojo test is improved a bit though, mojo-pytest has been working well so far!
Walter Erquinigo
@Lily Brown FYI
Helehex
Helehex4mo ago
im getting a warning for each test warning: (x86_64) /home/helehex/mojo-code/infrared/.magic/envs/default/lib/libstdc++.so.6 unsupported DW_FORM value: 0x1e when running mojo test inside a magic project not sure what to do about the tests where i'm testing every possible dtype parametrically. I guess i could make them capturing functions oh i just thought of a nice way i think
Darin Simmons
Darin Simmons4mo ago
I put a bug report in for something very similar and was told it will be fixed in 24.5 https://github.com/modularml/max/issues/194
GitHub
[Magic CLI]: Invoking REPL returns DW_Form warning · Issue #194 · m...
Issue description Inside a project environment and shell, running mojo REPL returns warning (github code copy icon is covering the last part which reads "0x1e", if you slide the bar AND h...
btokarzewski
btokarzewski4mo ago
@toasty adding -I and specifying src worked for me. I attach a screenshot for reference.
No description
btokarzewski
btokarzewski4mo ago
I also added a task to mojoproject.toml so I can just type "magic run test" [tasks] test = {cmd = "mojo test -I src test"}
Want results from more Discord servers?
Add your server