Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hacks around Minitest internals, make peace with Minitest.autorun #514

Merged
merged 3 commits into from
May 19, 2015

Conversation

latortuga
Copy link
Collaborator

We want to run Minitest via Minitest.run. Rails requires 'minitest/autorun' when requiring 'rails/test_help' which means invoking Minitest.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 Rails test_helper against mucking with Minitest's internals and I'm definitely open to other ways of passing proper arguments into Minitest.run.

@blowmage I would also appreciate your thoughts on this.

Instead of trying to hack around Minitest internals, we'll simply hook into
the way that they internally call Minitest.run(ARGV) by replacing ARGV with
our desired test arguments. This is arguably a hack because we're mangling
ARGV but Minitest has executed with ARGV explicitly passed in for at least
two major releases so we'll go with it for now.
@blowmage
Copy link

Where are you seeing Rails require minitest/autorun? That loads the spec DSL and Rails has been very careful not to do that.

@latortuga
Copy link
Collaborator Author

@blowmage
Copy link

Gotcha. This seems like a decent compromise. Interested to know what @zenspider thinks.

This uses the same strategy as Minitest, namely replacing ARGV and running
via RSpec's native autorun hook.
latortuga added a commit that referenced this pull request May 19, 2015
Remove hacks around Minitest internals, make peace with Minitest.autorun
@latortuga latortuga merged commit 80d5b6b into burke:master May 19, 2015
@latortuga latortuga deleted the minitest-autorun branch May 19, 2015 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants