How do you set up a directory structure for a multi-file project with test files and doc files? How do you name the files and how do you run tests?
I'm trying to follow this page without much luck:
https://github.com/nim-lang/nimble#project-structure
I get an error building my main project because the compiler cannot create the exe which has the same name as the directory for source files. Also the compiler cannot find the imports when building the test files even though I have a nim.cfg file.
the compiler cannot find the imports when building the test files even though I have a nim.cfg file.
You can use the compiler option path = "$projectDir".
Thanks for all the helpful advice.
I am trying out this structure:
bin
docs
tests
nim.cfg which contains one line: --path:"../project/"
test_project.nim
test_file1.nim
project.nimble
project
project.nim
file.nim
private
t.nim
project.nimble contains tasks for compiling source, tests and docs. The binary files go in the bin folder, the html files go in the docs folder. Below are the tasks in the nimble file. Run "nimble m" to build and run the main project file.
skipDirs = @["tests", "private"]
task m, "Build and run project":
exec "nim c -r --out:bin/project project/project"
task test, "test project":
exec "nim c -r --out:bin/test_project tests/test_project"
task test_file1, "test file1":
exec "nim c -r --out:bin/test_file1 tests/test_file1"
task docs, "Build all the docs":
exec "nim doc --out:docs/project.html project/project.nim"
exec "nim doc --out:docs/file1.html project/file.nim"
task tree, "Show the directory tree":
exec "tree -I '*~|nimcache'"