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

Stop gap solution for long output on test cases #45882

Merged
merged 2 commits into from Aug 24, 2022

Conversation

tenderlove
Copy link
Member

This patch just changes the inspect method on test case instances.
Seeing test instance internals probably isn't helpful when an exception
is raised (for example a NoMethodError).

This isn't as good as #45122, but should fix #45121

I don't think this is great, but should fix the immediate pain. This does make me think we should have an API in Ruby for telling inspect what instance variables we would like it to use.

The implementation of inspect simply loops over all instance variables, but interestingly it doesn't call the instance_variables method to determine what IVs to inspect.

To me, it feels like these two objects should have different inspect output, but they don't:

class Foo
  def initialize
    @foo = 1
    @bar = 1
  end
end

class Bar < Foo
  def instance_variables
    [:@foo]
  end
end

p Foo.new
p Bar.new

Anyone have any thoughts on this PR or the above thing? I'm happy to file a redmine ticket wrt the inspect feature.

This patch just changes the inspect method on test case instances.
Seeing test instance internals probably isn't helpful when an exception
is raised (for example a `NoMethodError`).

This isn't as good as #45122, but should fix #45121
Copy link
Member

@byroot byroot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me as a quick fix than we can easily backport until the full solution comes around.

Co-authored-by: John Hawthorn <john@hawthorn.email>
@tenderlove tenderlove merged commit fd9308a into main Aug 24, 2022
@tenderlove tenderlove deleted the short-inspect-on-test-case branch August 24, 2022 20:45
tenderlove added a commit that referenced this pull request Aug 24, 2022
Stop gap solution for long output on test cases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Very long test output even for simple failing tests
3 participants