Hi all,
I have two test files test_x.nim, test_y.nim in my test directory. I am using this Nimscript to run my tests:
task test, "Runs the test suite":
configForTests()
var dir_list = listDirs("test")
dir_list.add("test")
keepItIf(dir_list, it != "test/nimcache")
for dir in dir_list:
for file in listFiles(dir):
var (_, _, ext) = splitFile(file)
if ext == ".nim":
echo "running ---- " & file
setCommand "c", file
When I run $nimble test, I get the correct echo output
running ---- test/test_x.nim
running ---- test/test_y.nim
but only test_x.nim gets compiled! test_y is ignored. Any ideas as to what I'm doing wrong here ?
Edit: deleted the part about setCommand ending the nimble run. Maybe the solution works anyway.
One possible solution: make testing a file a task of its own named e.g. testFile and call it as often as needed from another task like this:
exec "nimble testFile <whatever call parameters are needed>"
Inside testFile, the call parameters can be read with paramStr(i). Not the most elegant way perhaps, but it works. Maybe selfExec would be better, but that crashed on me IIRC.After some more experimentation I went with his:
task test, "Runs the test suite":
configForTests()
var dir_list = listDirs("test")
dir_list.add("test")
keepItIf(dir_list, it != "test/nimcache")
for dir in dir_list:
for file in listFiles(dir):
var (_, _, ext) = splitFile(file)
if ext == ".nim":
echo "running ---- " & file
exec r"nim c -r " & file