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

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -