main()s often also just do
os.Exit(run()). Passing the command line arguments run
run(…) seems like another obvious thing to do. Even though, I should have done this more consistently, I reckon. I feel very stupid now, because for whatever reason, it never occurred to me to simply pass an
io.Writer for stdout. I really like that. Although, I’m wondering why there’s nothing for stderr. Errors should definitely not mix with other output in my opinion. Anyways. When testing, I always captured stdout with a much more complicated code segment so far. Store the original output and error streams, set the new ones, execute the test, convert things to strings and finally reset to the original streams. I will definitely adopt these
io.Writer arguments. Thanks, mate! :-)
This cmdtest test execution also captures the coverage? It looks kinda more complicated than it should be, otherwise. Just a program with the test definition file would be enough in my opinion.
I don’t know if I like the concept of providing a single test definition file or not. It’s a bit intriguing, but I fear that’s not flexible enough. Just a gut feeling, might be wrong.