Thread overview | |||||
---|---|---|---|---|---|
|
September 04, 2022 Why do failed contracts don't dump stack backtrace in unittests? | ||||
---|---|---|---|---|
| ||||
The program output is different whether an Error is thrown from main or from the unittest block: void foo(string s) in (s != "hello") { } unittest { foo("hello"); // No stack backtrace } void main() { foo("hello"); // Yes stack backtrace } Ali |
September 04, 2022 Re: Why do failed contracts don't dump stack backtrace in unittests? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Sunday, 4 September 2022 at 14:14:55 UTC, Ali Çehreli wrote: > The program output is different whether an Error is thrown from main or from the unittest block: Because the default test runner catches the Error, and doesn't print the stack trace: https://github.com/dlang/dmd/blob/25799d3841ea87246c56532f6f91d9a1e34d8d8f/druntime/src/core/runtime.d#L599-L620 There's even a comment about it: // TODO: omit stack trace only if assert was thrown // directly by the unittest. |
September 04, 2022 Re: Why do failed contracts don't dump stack backtrace in unittests? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Backus | On 9/4/22 09:35, Paul Backus wrote:
> // TODO: omit stack trace only if assert was thrown
> // directly by the unittest.
Thank you but I mean... :) I can understand removing a backtrace from the eyes of an end user but the consumer of a unittest output is a developer, no?
Ali
|
Copyright © 1999-2021 by the D Language Foundation