M
Modular7mo ago
Aamir

Need Opinion! Best Practices for Directory Structure and Unit Testing in Mojo Library?

Hello Mojo, I'm currently working on a library project in Mojo :mojo: and I'm seeking some advice to ensure that my project is well-organized and follows best practices. Directory Structure: I have a basic directory structure in place, which looks like this:
<lib-project>
| .temp # for temporary files
| .gitignore
| <lib_name>
| | __init__.mojo
| | lib.mojo
| | lib_tests.mojo
| dependencies # for storing dependent libraries
| | <lib-a>
| | <lib-b>
| LICENSE
| README.md
<lib-project>
| .temp # for temporary files
| .gitignore
| <lib_name>
| | __init__.mojo
| | lib.mojo
| | lib_tests.mojo
| dependencies # for storing dependent libraries
| | <lib-a>
| | <lib-b>
| LICENSE
| README.md
I'm not entirely sure if this is the most efficient or conventional way to organize a Mojo library project. I would love to hear your recommendations on the ideal directory structure. Specifically, how do you usually organize dependencies? And do you keep the library code separate from other source files? Any examples of well-structured Mojo library projects would be greatly appreciated. Unit Testing: I'm also looking to implement unit tests for my project. Since Mojo is relatively new, I'm not aware of any specific testing frameworks available for it. Thank you all in advance for your help and guidance. I'm looking forward to learning from your experiences and improving my project based on your advice.
3 Replies
Ehsan M. Kermani (Modular)
Hi Aamir! thanks for putting this together. Your suggestions look good to me. For testing, have a look at stdlib testing module https://docs.modular.com/mojo/stdlib/testing/testing. There's no best practices in terms of repo structure. We might have one in the future.
Aamir
Aamir6mo ago
👍🏼
a2svior
a2svior6mo ago
I personally try to keep to Python conventions for this
Want results from more Discord servers?
Add your server