Thread overview
[Issue 11362] New: Unit test assertion failure messages not printed
Oct 26, 2013
Jacob Carlborg
Oct 26, 2013
Ali Cehreli
Oct 28, 2013
Walter Bright
Oct 28, 2013
Walter Bright
Oct 28, 2013
Ali Cehreli
Oct 28, 2013
Walter Bright
Oct 28, 2013
Denis Shelomovskij
Oct 29, 2013
Walter Bright
Oct 29, 2013
Walter Bright
October 26, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11362

           Summary: Unit test assertion failure messages not printed
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: druntime
        AssignedTo: nobody@puremagic.com
        ReportedBy: doob@me.com


--- Comment #0 from Jacob Carlborg <doob@me.com> 2013-10-26 05:06:03 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 26, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11362


Ali Cehreli <acehreli@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |acehreli@yahoo.com


--- Comment #1 from Ali Cehreli <acehreli@yahoo.com> 2013-10-26 11:38:23 PDT ---
I confirm this on Linux as well.

(At least the program returns non-zero status code.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 28, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11362


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |WORKSFORME


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2013-10-27 23:29:47 PDT ---
The sample program works correctly for me on Win32, Linux and OSX.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 28, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11362



--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2013-10-27 23:30:18 PDT ---
As of dmd 2.064 beta 4, that is.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 28, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11362



--- Comment #4 from Ali Cehreli <acehreli@yahoo.com> 2013-10-27 23:56:18 PDT ---
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
core.exception.AssertError@good.d(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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 28, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11362


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WORKSFORME                  |


--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> 2013-10-28 00:14:40 PDT ---
(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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 28, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11362


Denis Shelomovskij <verylonglogin.reg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |verylonglogin.reg@gmail.com


--- Comment #6 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2013-10-28 23:14:57 MSK ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 29, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11362



--- Comment #7 from github-bugzilla@puremagic.com 2013-10-28 18:51:58 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 29, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11362


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 29, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11362



--- Comment #8 from Walter Bright <bugzilla@digitalmars.com> 2013-10-28 18:52:57 PDT ---
https://github.com/D-Programming-Language/druntime/pull/648

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------