-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Fix minitest test_prelude
#102
Conversation
to prepare for mutating the object under test in the next commit
to ensure the test command matches pre-v3.18.0 behavior
unless and until seattlerb/hoe#102 is merged to fix our coverage calculation issue related to #1965
to work around SimpleCov coverage being broken until seattlerb/hoe#102 is merged
@zenspider just a gentle ping on this - let me know if you'd like a different approach taken to address my issues. thanks for all your work. |
Just saw your ping... I'm poking. I think your approach is fine, but your tests all pass w/o any patch to lib so they won't prevent a regression. |
AH. OK... I figure out what's going on. The tests are always going against the old |
Please verify: # here just for comparison:
EXPECTED = %W[-w -Ilib:bin:test:.
-e 'require "rubygems"; %srequire "test/test_hoe_test.rb"'
--].join(" ") + " "
MT_EXPECTED = %W[-Ilib:test:. -w
-e '%srequire "test/test_hoe_test.rb"'
--].join(" ") + " "
require "minitest/test_task" # currently in hoe, but will move
def test_make_test_cmd_for_minitest
skip "Using TESTOPTS... skipping" if ENV["TESTOPTS"]
framework = %(require "minitest/autorun"; )
@tester = Minitest::TestTask.create :test do |t|
t.libs += Hoe.include_dirs.uniq
t.test_globs = ["test/test_hoe_test.rb"]
end
assert_equal MT_EXPECTED % [framework].join("; "), @tester.make_test_cmd
end
def test_make_test_cmd_for_minitest_prelude
skip "Using TESTOPTS... skipping" if ENV["TESTOPTS"]
prelude = %(require "other/file")
framework = %(require "minitest/autorun"; )
@tester = Minitest::TestTask.create :test do |t|
t.test_prelude = prelude
t.libs += Hoe.include_dirs.uniq
t.test_globs = ["test/test_hoe_test.rb"]
end
assert_equal MT_EXPECTED % [prelude, framework].join("; "), @tester.make_test_cmd
end |
The tests you put inline above look good to me, and reflect the expected behavior. Thanks! |
Would you like me to resubmit this PR with your suggested test structure? |
I already got ya (9b07634). I should have closed this. I'll ship nowish. |
Thank you! |
This PR addresses two issues:
lib/hoe/test.rb
, the use ofself.test_prelude
within aMinitest::TestTask.create
block doesn't do what's intended, because the block is beinginstance_eval
ed in the context of theTestTask
. As a result,t.test_prelude
is always blank, breakingtest_prelude
functionality completely.This PR uses a temporary variable outside the block to pass this value into the block:
lib/minitest/test_task.rb
the order of the framework snippet and the prelude snippet are reversed as compared to the pre-v3.18.0 implementation.Where previously this code put the prelude in front of the framework snippet:
The current code reverses this sense:
This PR restores the original order, which as it turns out is critical to getting SimpleCov to work with Minitest. (See sparklemotion/nokogiri#1965 for the SimpleCov-related problem that spawned this particular yak shave!)