www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11362] New: Unit test assertion failure messages not printed

reply d-bugmail puremagic.com writes:
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



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: -------
Oct 26 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11362


Ali Cehreli <acehreli yahoo.com> changed:

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



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: -------
Oct 26 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Oct 27 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11362




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: -------
Oct 27 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11362




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: -------
Oct 27 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11362


Walter Bright <bugzilla digitalmars.com> changed:

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



00:14:40 PDT ---

 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: -------
Oct 28 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Oct 28 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11362




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


https://github.com/D-Programming-Language/druntime/commit/191b6e4b80f6945bd1d1b2760da376893155ee7c


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: -------
Oct 28 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
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: -------
Oct 28 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11362




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: -------
Oct 28 2013