Bug 11362 – Unit test assertion failure messages not printed

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-26T05:06:00Z
Last change time
2013-10-28T18:52:57Z
Assigned to
nobody
Creator
doob

Comments

Comment #0 by doob — 2013-10-26T05:06:03Z
extern (C) int printf (in char*, ...); unittest { printf("Reached unittest.\n"); assert(0); printf("After failed assertion.\n"); } void main () { } The above code should print Reached unittest core.exception.AssertError@main(7): unittest failure And a stack trace. But after commit [1] it only prints "Reached unittest.". [1] https://github.com/D-Programming-Language/druntime/commit/db7dc40ad4a8e9ea9827224d8d4d799ef24810ca
Comment #1 by acehreli — 2013-10-26T11:38:23Z
I confirm this on Linux as well. (At least the program returns non-zero status code.)
Comment #2 by bugzilla — 2013-10-27T23:29:47Z
The sample program works correctly for me on Win32, Linux and OSX.
Comment #3 by bugzilla — 2013-10-27T23:30:18Z
As of dmd 2.064 beta 4, that is.
Comment #4 by acehreli — 2013-10-27T23:56:18Z
Well, this is broken on git head then. The following session compares two programs with a single assert expression. One has it in main: good.d: void main() { assert(false, "something is wrong"); } The other has it in a unittest block: unittest { assert(false, "something is wrong"); } void main() {} Under Linux (SL6), the former prints both the assertion failure message and the stack trace; the latter does not do any of that. The consolation is that the latter returns a non-zero error code. Here is my interaction: $ ./wbd | grep DMD DMD64 D Compiler v2.064-devel-acc0cb0 $ cat good.d void main() { assert(false, "something is wrong"); } $ ./wbd good.d $ ./good [email protected](3): something is wrong ---------------- ./good() [0x401a65] ./good() [0x4019c1] ./good() [0x401ecc] ./good() [0x401c8e] ./good() [0x401e8b] ./good() [0x401c8e] ./good() [0x401c0f] ./good() [0x4019e3] /lib64/libc.so.6(__libc_start_main+0xfd) [0x301621ecdd] $ echo $? 1 $ cat bad.d unittest { assert(false, "something is wrong"); } void main() {} $ ./wbd bad.d -unittest $ ./bad $ echo $? 1
Comment #5 by bugzilla — 2013-10-28T00:14:40Z
(In reply to comment #4) > Well, this is broken on git head then. Evidently. The commit identified above is not in the 2.064 beta. I'll reopen then for 2.065.
Comment #6 by verylonglogin.reg — 2013-10-28T13:14:57Z
https://github.com/D-Programming-Language/druntime/pull/648 P.S. This issue is an example of how people like to kill "needless" safe utils and start use of C standard library. Here we are happy it's just a coder mistake that almost nobody of experienced developers discovered but there are also C library bugs in our world. IMO, we should kill the usage of C library instead and provide small fast wrappers of OS API like the late `rt.util.console` did.
Comment #7 by github-bugzilla — 2013-10-28T18:51:58Z
Commits pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/65f39b163dc7b23de257cd6d0018ef485923716e Issue 11362 - Unit test assertion failure messages not printed Issue URL: http://d.puremagic.com/issues/show_bug.cgi?id=11362 Regression commit from pull #636: db7dc40ad4a8e9ea9827224d8d4d799ef24810ca https://github.com/D-Programming-Language/druntime/commit/191b6e4b80f6945bd1d1b2760da376893155ee7c Merge pull request #648 from denis-sh/fix-issue-11362 Issue 11362 - Unit test assertion failure messages not printed
Comment #8 by bugzilla — 2013-10-28T18:52:57Z