Remove hacks around Minitest internals, make peace with Minitest.autorun #514
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.
We want to run Minitest via
Minitest.run
. Rails requires'minitest/autorun'
when requiring'rails/test_help'
which means invokingMinitest.run(our_arguments)
will cause tests to get run twice, once with our arguments and once with ARGV via autorun.Instead of trying to hack around Minitest class variables and prevent autorun from working, we'll stop fighting it and let Minitest run our desired tests by replacing ARGV with our desired test arguments and letting autorun invoke the tests when the child processes exit. This is still a bit of an introspection of Minitest's API because we're mangling ARGV but Minitest has executed with ARGV explicitly in autorun for at least two major releases so we'll go with it for now.
Previously discussed here.
@zenspider I welcome any feedback on this mechanism for hooking into
autorun
. I'm trying to balance working out of the box with standard Railstest_helper
against mucking with Minitest's internals and I'm definitely open to other ways of passing proper arguments intoMinitest.run
.@blowmage I would also appreciate your thoughts on this.