Stream: ideas

Topic: show dbg only for failed expect


view this post on Zulip Johannes Maas (Nov 22 2026 at 10:49):

When running roc test, have you considered showing the output of dbg only for expects which failed? I have tried to search Zulip, but haven't found a discussion of this.

I think this is different from inspecting the used values, which I found is currently not available but will come back after v0.1.0: #beginners > How to see values from failing top-level `expect` statements @ 💬

The difference is that I might have some dbg statements in my functions, not inside my test. These clutter the output of roc test making it difficult for me to distinguish which are related to the failing test I want to know more about.

The dbg in the test code I can hide behind an if, so even without the automatic display of used values I can output the relevant values only when the test fails, which cleans up the output of roc test and makes it easier to understand what went wrong.

But I think this is not possible for dbg inside the functions under test, which I might want to do to understand each step inside the function. Here, I think I would need support from roc test to clean up the output.

I think I've seen this behavior of only outputting logs from failed tests in Jest, but I have trouble finding documentation on this, so I'm not sure if I remember that correctly.

I thought I'd share the idea in case this is something that others might find useful as well.

view this post on Zulip Aurélien Geron (Nov 22 2026 at 19:04):

Interesting. This could perhaps be a command line option like --dbg-on-fail or --quiet?

view this post on Zulip Richard Feldman (Nov 22 2026 at 20:00):

I'd like to try making it so that:

view this post on Zulip Richard Feldman (Nov 22 2026 at 22:01):

hrm, there is a problem here: if we make that change, it becomes very painful to debug an infinite loop in tests.

view this post on Zulip Richard Feldman (Nov 22 2026 at 22:02):

because we have to hold the output for each test until we know whether it failed or not, and if it's not terminating we never find out, so we don't print any dbg output, and then you have no way to use dbg to tell how far it's getting

view this post on Zulip Johannes Maas (Nov 23 2026 at 06:46):

I think there might be use cases for both outputting all and outputting only for failing tests. So there would need to be a config flag, as Aurélien suggested.

One option would be to print all by default and if there are outputs for successful tests to give a hint at the end of the report of which flag to use to only show the failing outputs.

That way in your case you would see the output on the infinite loop by default, but if you are overwhelmed by the outputs it would guide you to how to clean them up.

view this post on Zulip Richard Feldman (Nov 23 2026 at 19:08):

I'd rather not do the config flag thing...that's what cargo test does and it was always super annoying whenever I had to debug a hung test because I'd have to kill the run and re-run with the flag, and then the output was super noisy

view this post on Zulip Richard Feldman (Nov 23 2026 at 19:09):

maybe a better design is to have some timing threshold (which is configurable), and if a test is taking longer than that amount of time, we start showing its dbg output in realtime

view this post on Zulip Richard Feldman (Nov 23 2026 at 19:10):

so that way if only 1 test is hung and all the others are fine, you still only see the dbg output of the one that's looping, and also you don't need to restart the whole run with a different flag

view this post on Zulip Richard Feldman (Nov 23 2026 at 19:11):

relatedly, even if there is no dbg, it could be useful to say "[some test] has been running for 5s" and have that tick up in realtime so if you're wondering why the run is taking so long, you immediately know what culprit is holding up the show without having to restart


Last updated: Nov 26 2026 at 20:35 UTC