youki
youki copied to clipboard
Make failure message great again
Right now if we had a test failed when run cargo test
, the failure message is missing and we can not locate the assert that failed directly.
And if comment the tests code in tty.rs
, the failure message show up again. Just like the failure message is eaten by the tty.
Failure test without commenting tests in tty.rs.
Failure test with commenting tests in tty.rs.
It would be a little annoying for debugging when CI failed. So maybe we should find a way to make failure message come back.
cc @utam0k
/assign
@utam0k I wasn't sure if you want to add --nocapture
to cargo test
on CI as a solution? This issue is asking for that.
@utam0k I wasn't sure if you want to add
--nocapture
tocargo test
on CI as a solution? This issue is asking for that.
That may be fine for CI, but what about local execution unit tests...
Sorry I don't follow. For local unit test, you also run cargo test -- --nocapture
to see the error output in case test fails when developing. It works exactly the same.
@utam0k @yihuaf
I think nocapture
can not meet the requirement of this issue.
https://doc.rust-lang.org/cargo/commands/cargo-test.html#display-options
It seems that the nocapture
option means do not capture the output of our tested binary
, something like println
in our code.
But this issue is looking for the output information by rust test
, something like which assert in which file is failed (The difference between two screenshots in the description.)
But maybe add nocapture
to CI is also a good advice.
I agree with this. However, I don't think this is the root solution.
But maybe add nocapture to CI is also a good advice.
It seems that the nocapture option means do not capture the output of our tested binary, something like println in our code. But this issue is looking for the output information by rust test, something like which assert in which file is failed (The difference between two screenshots in the description.)
I may be misunderstanding the request for this issue. From the link, I read:
By default the Rust test harness hides output from test execution to keep results readable. Test output can be recovered (e.g., for debugging) by passing --nocapture to the test binaries:
The information about which assert failed in which line is exactly the info outputted by --nocapture
, in addition to the logs and println. There is also the -v
and -vv
flag to output additional info for the test build scripts and etc.
Anyhow, you seem to have a clear idea of what you'd like to accomplish in this issue, so I will leave you to it.
The information about which assert failed in which line is exactly the info outputted by --nocapture, in addition to the logs and println. There is also the -v and -vv flag to output additional info for the test build scripts and etc.
I do have a try on add nocapture
to the test, and it won't help.(I deliberately change the code to make test failed)
The output here does not have
which assert in which file failed
.
And if comment the tests code in tty.rs, the failure message show up again. Just like the failure message is eaten by the tty.
And here is the point I think.
Anyhow, you seem to have a clear idea of what you'd like to accomplish in this issue, so I will leave you to it.
Actually I have no idea how to deal with it right now, any suggestion is welcome.
And if comment the tests code in tty.rs, the failure message show up again. Just like the failure message is eaten by the tty.
And here is the point I think.
Somehow I overlooked this line. Stupid me... You are right, what I mentioned is not a solution. The root cause is likely something else isolated to the tty tests.
And if comment the tests code in tty.rs, the failure message show up again. Just like the failure message is eaten by the tty.
And here is the point I think.
Somehow I overlooked this line. Stupid me... You are right, what I mentioned is not a solution. The root cause is likely something else isolated to the tty tests.
ah never mind, the screen shot is too big to see the words. 😆