Comments (11)
hi @mingwugmail
I did not removed any code related to the stack printing. Can you tell me more about your issue? maybe you can paste the test that does not print the stack trace?
What version of the library and compiler are you currently using?
from fluent-asserts.
Oh, I mean the full stack trace. I did saw the current frame, but I want to see the full stack trace all the way up to the root main().
from fluent-asserts.
The library throws an exception in case one of your asserts fail and the runtime will print the exception with it's stack trace.
From what I understand, you might have a setup problem. Without more details I can't do much to help.
from fluent-asserts.
ok, a small example:
/+dub.sdl:
dependency "fluent-asserts" version= "~>0.13.3"
+/
import std.stdio;
import fluent.asserts;
void f2() {
int k = 3;
Assert.equal(k, 4);
}
void f1() {
int j = 2;
f2();
}
void f0() {
int i = 1;
f1();
}
void main() {
f0();
}
the current fail message, only show the current stack frame of f2()
$ dub.exe sf.d
[email protected](10): k should equal `4`.
Expected:4
Actual:3
--------------------
sf.d:10
--------------------
6:
7:
8: void f2() {
9: int k = 3;
> 10: Assert.equal(k, 4);
11: }
----------------
what I want to see, all the call stack, f2(), f1(), f0(), all the way up to main(), e.g.:
sf.d:10
--------------------
6:
7:
8: void f2() {
9: int k = 3;
> 10: Assert.equal(k, 4);
11: }
----------------
f1() {
...
> f2();
----------------
f0() {
...
> f1();
----------------
main() {
...
> f0();
And better: for each stack frame, also print out its local variable values.
Is this possible in D?
Thanks.
from fluent-asserts.
It is definitely possible to print the variable values, but this is not a trivial task and there is no library support for this.
It looks like it is a compiler dmd issue. I am using the dmd 2.91.0 on linux and mac and I get the stack trace:
fluentasserts.core.base.TestException@source/app.d(10): k should equal `4`.
Expected:4
Actual:3
--------------------
source/app.d:10
--------------------
6:
7:
8: void f2() {
9: int k = 3;
> 10: Assert.equal(k, 4);
11: }
----------------
../../source/fluentasserts/core/base.d:61 @safe void fluentasserts.core.base.Result.perform() [0x5e2ad3]
../../source/fluentasserts/core/base.d:65 @safe void fluentasserts.core.base.Result.__dtor() [0x5e2af0]
../../source/fluentasserts/core/base.d:601 @safe void fluentasserts.core.base.Assert.opDispatch!("equal", int, int).opDispatch(int, int, immutable(char)[], const(immutable(char)[]), const(ulong)) [0x5de297]
source/app.d:10 void app.f2() [0x5dc967]
source/app.d:15 void app.f1() [0x5dc983]
source/app.d:20 void app.f0() [0x5dc99b]
source/app.d:24 _Dmain [0x5dc9a8]
Program exited with code 1
from fluent-asserts.
I'm expecting that you don't see the stack trace of any exception thrown in your app.
from fluent-asserts.
oh, I got that too, up to d_run_main, but
- I had hoped to saw every stack frame printed nicely as the last frame:
--------------------
sf.d:10
--------------------
6:
7:
8: void f2() {
9: int k = 3;
> 10: Assert.equal(k, 4);
11: }
----------------
- and in my multi-threaded program, I indeed only got the last frame. It will take me some time to write another multi-threaded program to show you the example.
from fluent-asserts.
Ah... I see you want to see the source for each frame. The library was never designed to do this. The purpose of the source is too see which assert failed, which it looks like it works well.
Unfortunately, showing detailed info about your stack, is not possible with fluent asserts. To achieve this, you can use a debugger.
from fluent-asserts.
ok 1) is not possible, I will see if I can make a small example for 2).
from fluent-asserts.
when you create a new thread, it will have a new stack, and no reference to where it was started. I'm not sure how you would see a stack trace up to your main function, since the stack frames that started the thread might not exist when your assert is triggered.
from fluent-asserts.
Yes, you are right. I do see the stack start from the thread.run().
Thanks.
from fluent-asserts.
Related Issues (20)
- v1.0.0 Assert.equal(double, int literal) behave different from v0.13.3 HOT 2
- v1.0.0 cannot Assert.lessThan(std.checkedint, std.checkedint); while v0.13.3 can
- exception with message does not show the right sourcecode
- the HTTP Request has the port 0 HOT 1
- Comparing const array of classes gives compile error HOT 3
- should.containOnly and should.equal fail on a range of ranges
- Deprecation of `this` as a Type HOT 2
- Dependencies Fail to Build with Fluent Asserts 0.12.3 & DMD v2.083.1 HOT 2
- should() for std.range.interfaces.InputRange returns ShouldObject
- Move vibe.d support to a separate package HOT 3
- Should fails when trying to compare std.container.array Ranges. HOT 2
- feature request: add func to report total count of assertion failure, Assert.count()?
- no notLessThan for 2 strings? also no Assert.greaterEqualThan, Assert.lessEqualThan? HOT 5
- is there a build config string, that will turn off all asserts into no-op? HOT 4
- strange error message: results.d(1192): Range violation
- Comparing Arrays does (sometimes) not work. Problem with Objects? HOT 4
- throwException!T.original returns different Type in 0.14 alpha HOT 4
- opEquals() is not honoured with 0.14 alpha 8 HOT 4
- v1.0.0 cause Program exited with code -11 (v0.13.3 is fine) HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluent-asserts.