You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix minitest reporter crash with parallel testing (#3602)
### Motivation
Fix crash when using ActiveSupport's parallel testing with the Minitest reporter. When running tests in parallel, ActiveSupport passes a `PrerecordResultClass` wrapper (a Struct containing only the class name) instead of the actual test class, since class objects cannot be marshaled across process boundaries via DRb.
### Implementation
Updated the `prerecord` method in MinitestReporter to handle both regular test classes and ActiveSupport's wrapper objects:
- Renamed parameter from `test_class` to `test_class_or_wrapper` to clarify it can receive different types
- Extract the class name using `.name` (which both real classes and the `PrerecordResultClass` wrapper respond to)
- Attempt to resolve the actual class using `Object.const_get`
- If `const_get` fails (e.g., for Minitest specs with invalid constant names like `"MySpec::when something is true"`), use the original object since it's already the test class
- Continue with the existing logic using the resolved class
This approach handles three scenarios:
- Regular test classes: `const_get` successfully resolves the class
- ActiveSupport's PrerecordResultClass: Contains the class name as a string, `const_get` retrieves the actual class from the main process
- Minitest specs with describe blocks: `const_get` fails due to invalid constant names (with spaces), but we already have the class object
### Manual Tests
To test these changes:
1. Open a Rails project that uses ActiveSupport's parallel testing
2. Run tests using the Ruby LSP test runner
3. Verify that test results are correctly reported in the Test Explorer view
0 commit comments