Shopify / Shopify/type_toolkit
Make `UnexpectedNilError` un-rescueable from tests
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 3
- Forks
- 5
- Avg merge
- 8d 23h
- Merged PRs (30d)
- 8
Description
It currently inherits from Exception, so that a bare rescue => e doesn't unintentionally rescue it. We've already run into a real-world case where that proved useful, where a fork of the not_nil! implementation made it derive from StandardError, which indeed hid a test failure (only detected because we switched that copy of the code to use Type Toolkit).
To make it truly uncatchable, we can do something like throw Object.new. In a production app, this would crash your Rails app with UncaughtThrowError, so we'd have to limit it to tests. But we also don't want to crash minitest/RSpec, so we'd need to wrap the test runner in a catch call. We would need some kind of secret-ish tag to throw, that only the test runner can catch.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating UnexpectedNilError and the not_nil! implementation, then inspect how the project invokes minitest or RSpec. Determine how tests can prevent a bare rescue => e from hiding this error without crashing the test runner. Done means the error remains unrescueable by ordinary test code while minitest and RSpec continue to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100