Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify backtrace-related assertions #680

Merged
merged 2 commits into from
Nov 9, 2024

Conversation

floehopper
Copy link
Member

Previously we were generating the expected backtrace-related strings from scratch, but that was (a) quite complicated; and (b) suffered from Ruby version differences. Now we're using strings obtained directly from a Ruby backtrace which is a lot simpler and avoids the Ruby version differences.

Verified

This commit was signed with the committer’s verified signature.
drazisil-codecov Joe Becher
Since the `ExecutionPoint` already stores the full backtrace, we should
already have it in the format for the relevant Ruby version. Using this
is a lot simpler than having to generate the line from scratch.
Since the `Expectation` instance already "knows" where it was defined,
it's simpler to use `Expectation#definition_location` to make these
assertions. And again, since this is obtained directly from the
backtrace, it should be in the format for the relevant Ruby version.
@floehopper floehopper merged commit f899c03 into main Nov 9, 2024
16 checks passed
@floehopper floehopper deleted the simplify-backtrace-related-assertions branch November 9, 2024 14:26
floehopper pushed a commit that referenced this pull request Dec 7, 2024
Since this change [1], lines in the stacktrace use an opening
single-quote instead of a backtick to delimit the method name, e.g.

    foo.rb:5:in 'Foo#bar': boom! (RuntimeError)

Instead of:

    foo.rb:5:in `Foo#bar': boom! (RuntimeError)

This commit makes a relevant assertion specific to the current Ruby
version.

This is somewhat similar to the fixes I put in place in #672, although
those were later considerably simplified in #680. Unfortunately I can't
see a way to achieve a similar simpification in this case.

[1]: https://bugs.ruby-lang.org/]issues/16495
floehopper pushed a commit that referenced this pull request Dec 7, 2024
Since this change [1], lines in the stacktrace use an opening
single-quote instead of a backtick to delimit the method name, e.g.

    foo.rb:5:in 'Foo#bar': boom! (RuntimeError)

Instead of:

    foo.rb:5:in `Foo#bar': boom! (RuntimeError)

This commit makes a relevant assertion specific to the current Ruby
version.

This is somewhat similar to the fixes I put in place in #672, although
those were later considerably simplified in #680. Unfortunately I can't
see a way to achieve a similar simpification in this case.

[1]: https://bugs.ruby-lang.org/]issues/16495
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant