rspec / rspec/rspec

Feature Request; Add support for failing tests that leak memory

Open
#26 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
117
Forks
51
Avg merge
59m
Merged PRs (30d)
3

Description

It would be useful to run rpsec tests with support for reporting and/or failing tests that exercise code that leaves referenced objects around. I had the pleasure of working with a C/C++ test framework that had this support and it was wonderful.

The gem memory_profiler ( https://github.com/SamSaffron/memory_profiler ) has code that makes testing for dangling object references pretty easy, but finding the right place to use that in rspec is difficult. I attempted using memory_profiler in before/after/around callbacks but it wasn't useful because rspec has allocated objects that need to stick around, and the leted variables complicate things even more. memory_profiler can be told to ignore allocations from rspec, but excluding the leted variables (and other test specific allocations) is significantly more difficult.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing memory_profiler's support for detecting referenced objects, then trace how RSpec's before, after, and around callbacks interact with framework allocations and let variables. The work is done when tests can report or fail on leaked references without counting allocations that RSpec or the test setup must retain.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
testing-qa
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.