templates - Unit Testing in Nim: Is it possible to get the name of a source file at compile time? -
i'm planning project multiple modules, , looking nice solution run existing unit tests in project @ once. came following idea: can run nim --define:testing main.nim
, use following template wrapper unit tests.
# located in general utils module: template rununittests*(code: stmt): stmt = when defined(testing): echo "running units test in ..." code
this seems working far.
as minor tweak, wondering if can print out file name calling rununittests
template. there reflection mechanism source file name @ compile time?
instantiationinfo seems want: http://nim-lang.org/docs/system.html#instantiationinfo,
template filename: string = instantiationinfo().filename echo filename()
Comments
Post a Comment