Suggestion: UnitTest Format


On OS X I was just trying to add a function marked extern “c” to a plugin so that it could be called by a command line app to perform some unit tests on the binary, however it seems due to the way the static library is linked with each of the formats the function never gets exported (I guess because it’s not referenced it gets stripped). I tried setting the file with my exported function in to compile in the VST wrapper target and sure enough it exported just fine.

Now there may be a way around the issue described above but it got me thinking if it might possibly be more useful to have a separate ‘UnitTest’ format. This would presumably prevent the unit tests from existing in the other formats so they can still go out the door as is, and it prevents a separated build / configuration to deal with UnitTests, I realise this may not be the case for Windows or Linux yet, but as a preliminary idea I wonder what others think.

I would expect the format to simply have an entry point such as runUnitTests() that returns an int to indicate failure or not, better still would be if the target could be marked as a command line application that implements main, I tend to have the runTests or main function return the number of failed tests in order to indicate failure or success.