Automatically drop into debugger or infiltrate on test error or failure

tl;dr: I’m looking for roughly the equivalent of pytest --pdb for those familiar with pytest.

I would like to drop into a debugger or infiltrator when a unit test fails. If I run a test and it fails and I can’t immediately figure it out, I rerun the test with @infiltrate sprinkled in. I feel like it would greatly improve my workflow if I could just have that as an option when I run my unit tests. Then I wouldn’t need to add and remove @infiltrate.

I was trying to wrap the @test macro, such that if it returned a fail or error result, it would run @infiltrate. I haven’t been clever enough to figure out how to do that however.

Edit: After some more thinking, this seems to work for me so far.

using Test
using Infiltrator

macro itest(ex, kws...)
    quote
        o = @test($(esc(ex)), $(esc.(kws)...))
        typeof(o) != Test.Pass && @infiltrate
        o
    end
end

Then I can just use @itest instead of @test.

1 Like

If something like this could be done outside of unit testing, that would be useful as well.

The use case would be, for example, a long running simulation with edge cases that I may not have anticipated. When the simulation fails, not having to rerun it after inserting @infiltrate would be a time saver.

1 Like

That’s what Rebugger.jl did. But it’s not currently maintained due to lack of humanpower. I’m happy to accept PRs to get it back in working order.

1 Like