Skip to content

fix(stacktrace): avoid duplicates in stacktrace for anonymous functions#11

Open
arikkfir wants to merge 1 commit intomainfrom
fix/prevent-same-line-stack-trace-printing
Open

fix(stacktrace): avoid duplicates in stacktrace for anonymous functions#11
arikkfir wants to merge 1 commit intomainfrom
fix/prevent-same-line-stack-trace-printing

Conversation

@arikkfir
Copy link
Copy Markdown
Owner

@arikkfir arikkfir commented May 11, 2024

This change avoids printing the same line twice in caller stack-traces when the direct caller to t.Fatalf is the same as the location that invoked the assertion (OrFail, For or Within).

Such a situation can happen when the direct caller is an anonymous function in the same line as the call to the assertion, for example:

With(t).Verify(...).Will(MatcherFunc(func(t T) { t.Fatalf(...) })).OrFail()

In this example both the call to OrFail as well as the direct call to t.Fatalf is on the same line, and the caller stack trace would print this line twice. This change prevents that.

@arikkfir arikkfir added the bug Something isn't working label May 11, 2024
@arikkfir arikkfir self-assigned this May 11, 2024
This change avoids printing the same line twice in caller stack-traces
when the direct caller to `t.Fatalf` is the same as the location that
invoked the assertion (`OrFail`, `For` or `Within`).

Such a situation can happen when the direct caller is an anonymous
function in the same line as the call to the assertion, for example:

    With(t).Verify(...).Will(MatcherFunc(func(t T) { t.Fatalf(...) })).OrFail()

In this example both the call to `OrFail` as well as the direct call to
`t.Fatalf` is on the same line, and the caller stack trace would print
this line twice. This change prevents that.
@arikkfir arikkfir force-pushed the fix/prevent-same-line-stack-trace-printing branch from b7debe2 to 3376a33 Compare May 11, 2024 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant