[dmd-internals] programs exit with error code 0 on unittest failure

Michel Fortin michel.fortin at michelf.com
Mon Jun 28 03:34:29 PDT 2010


Le 2010-06-27 à 17:30, Andrei Alexandrescu a écrit :

> When a unittest fails the program must end with a nonzero exit code. This has been the case until the last change (which I continue to dislike) that makes assert() only print an error message inside unittests.

I agree. There's two awkward things with how it works currently:

1. assert prints an error message, then the unittest continues. In all other unit test frameworks, the test abort, even though generally other tests after it are run.
2. When a unit test fails, the program runs as if nothing happened. I have a program that outputs a lot to the console, and it's easy to miss a few assertion errors at the top when the screen is quickly filled with the program's output and the errors go off screen.

Personally, I preferred the old behaviour, by a lot.

Assertions should be fatal errors. In a unit test it might be desirable to postpone exiting until the other tests are run, but that's useful mostly when displayed in conjunction with a list of failed tests. It's rarely useful to see multiple assertions within the same unittest{} block. And the program shouldn't be started (at least not by default) when a unit test has failed.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/





More information about the dmd-internals mailing list