Use -r instead of RUBYOPT to require LSP reporters #3661
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Motivation
I identified an issue we did not foresee. By requiring our custom reporters through
RUBYOPT, we end up causing any subprocesses spawned by the user's code to also require them. This can lead to weird issues.For example, if the user code raises, then our
at_exithook that checks for crashes will run and send a duplicatefinishevent to the explorer after we already closed the current run request. Since there's no current run, the explorer then thinks that this is a test being executed from the terminal manually and creates a fresh run with zero results inside.Note: it is possible that this is the infamous issue where spring prevents us from reporting test execution events, but I'm not 100% confident yet.
Implementation
Instead of trying to sanitize
RUBYOPT, which can become tricky very quickly, we should just move to using the-rcommand line argument for Ruby. That simply requires the reporter without cascading down to subprocesses and does what we want.Note: this is a breaking change because the Rails add-on will now need to add the same require to its command.