diff --git a/.travis.yml b/.travis.yml index 4b68088..248aef4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,19 @@ +language: ruby rvm: - - 2.4.0 - - 2.5.0 - - 2.6.0 + - 2.4 + - 2.5 + - 2.6 + - 2.7 + - 3.0 - jruby-9.2 before_install: + - yes | gem update --system --force - gem install bundler +gemfile: + - gemfiles/minitest4.gemfile + - gemfiles/minitest5.gemfile + - gemfiles/test_unit_gem.gemfile install: - bundle install - - bundle --gemfile=gemfiles/minitest5.gemfile - - bundle --gemfile=gemfiles/minitest4.gemfile - - bundle --gemfile=gemfiles/test_unit_gem.gemfile script: - - bundle exec rake tests + - bundle exec rake test diff --git a/Appraisals b/Appraisals index 46333e2..35e0e8e 100644 --- a/Appraisals +++ b/Appraisals @@ -1,9 +1,9 @@ appraise "minitest4" do - gem 'minitest', '4.7.5' + gem 'minitest', '~> 4' end appraise "minitest5" do - gem 'minitest' + gem 'minitest', '~> 5' end appraise "test_unit_gem" do diff --git a/Gemfile.lock b/Gemfile.lock index c3b5820..aab7177 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,36 +8,35 @@ PATH GEM remote: https://rubygems.org/ specs: - activesupport (4.0.13) - i18n (~> 0.6, >= 0.6.9) - minitest (~> 4.2) - multi_json (~> 1.3) - thread_safe (~> 0.1) - tzinfo (~> 0.3.37) + activesupport (6.1.4.1) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) allocation_stats (0.1.5) - appraisal (2.0.1) - activesupport (>= 3.2.21) + appraisal (2.4.1) bundler rake thor (>= 0.14.0) - benchmark-ips (2.1.1) + benchmark-ips (2.9.1) + concurrent-ruby (1.1.9) coveralls (0.8.23) json (>= 1.8, < 3) simplecov (~> 0.16.1) term-ansicolor (~> 1.3) thor (>= 0.19.4, < 2.0) tins (~> 1.6) - docile (1.3.1) - i18n (0.7.0) - json (2.2.0) - json (2.2.0-java) - method_source (0.8.2) - minitest (4.7.5) - multi_json (1.11.0) - mustache (1.0.2) - rake (10.4.2) - rdiscount (2.1.8) - redcarpet (3.3.2) + docile (1.4.0) + i18n (1.8.10) + concurrent-ruby (~> 1.0) + json (2.5.1) + method_source (1.0.0) + minitest (5.14.4) + mustache (1.1.1) + rake (13.0.6) + rdiscount (2.2.0.2) + redcarpet (3.5.1) rocco (0.8.2) mustache redcarpet @@ -46,13 +45,15 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) + sync (0.5.0) term-ansicolor (1.7.1) tins (~> 1.0) - thor (0.20.3) - thread_safe (0.3.5) - thread_safe (0.3.5-java) - tins (1.20.2) - tzinfo (0.3.44) + thor (1.1.0) + tins (1.29.1) + sync + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + zeitwerk (2.4.2) PLATFORMS java @@ -69,4 +70,4 @@ DEPENDENCIES rocco BUNDLED WITH - 1.17.2 + 2.2.26 diff --git a/README.md b/README.md index a64aa74..4407693 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ If you want to run all the tests in a directory as well as its subdirectories, u Finished in 3.459902s, 45.0880 runs/s, 87.5747 assertions/s. 156 tests, 303 assertions, 0 failures, 0 errors, 13 skips - + If you need to pass some option down to the actual runner, that is also supported: $ m test/models -- --seed 1234 @@ -120,7 +120,7 @@ If you need to pass some option down to the actual runner, that is also supporte Finished in 3.459902s, 45.0880 runs/s, 87.5747 assertions/s. 156 tests, 303 assertions, 0 failures, 0 errors, 13 skips - + Ensure that you use the `--` before the options, otherwise you'll get an invalid option error. Also, these extra option should always be the last argument. @@ -138,6 +138,17 @@ SUPPORT CONTRIBUTING ============ +## Setup + +This project uses [Appraisal](https://github.com/thoughtbot/appraisal) to test against different versions of dependencies. + +To install all scenarios (appraisals): + + bundle install + bundle exec appraisal install + +## Testing + You can run all the tests with: bundle exec rake tests @@ -148,11 +159,7 @@ You can also run tests selectively. For minitest 4 run: and the ones for minitest 5 with: - appraisal minitest5 rake test TEST=test/minitest_5_test.rb - -In the case of minitest 5, we have to specify the test to run, because running -the whole suite will fail due to incompatibilities with ruby (at least until -2.1.1). + appraisal minitest5 rake test LICENSE diff --git a/gemfiles/minitest4.gemfile b/gemfiles/minitest4.gemfile index 957edbf..8ea5e19 100644 --- a/gemfiles/minitest4.gemfile +++ b/gemfiles/minitest4.gemfile @@ -2,7 +2,9 @@ source "https://rubygems.org" -gem "coveralls", :require => false, :group => :coverage -gem "minitest", "4.7.5" +gem "coveralls", require: false +gem "benchmark-ips" +gem "allocation_stats" +gem "minitest", "~> 4" -gemspec :path => "../" +gemspec path: "../" diff --git a/gemfiles/minitest4.gemfile.lock b/gemfiles/minitest4.gemfile.lock index ee42c6e..3443f24 100644 --- a/gemfiles/minitest4.gemfile.lock +++ b/gemfiles/minitest4.gemfile.lock @@ -8,34 +8,36 @@ PATH GEM remote: https://rubygems.org/ specs: - activesupport (4.0.2) - i18n (~> 0.6, >= 0.6.4) + activesupport (4.0.13) + i18n (~> 0.6, >= 0.6.9) minitest (~> 4.2) multi_json (~> 1.3) thread_safe (~> 0.1) tzinfo (~> 0.3.37) - appraisal (0.5.2) + allocation_stats (0.1.5) + appraisal (2.4.1) bundler rake - atomic (1.1.14) - atomic (1.1.14-java) + thor (>= 0.14.0) + benchmark-ips (2.9.1) + concurrent-ruby (1.1.9) coveralls (0.8.23) json (>= 1.8, < 3) simplecov (~> 0.16.1) term-ansicolor (~> 1.3) thor (>= 0.19.4, < 2.0) tins (~> 1.6) - docile (1.3.1) - i18n (0.6.9) - json (2.2.0) - json (2.2.0-java) - method_source (0.9.2) + docile (1.4.0) + i18n (0.9.5) + concurrent-ruby (~> 1.0) + json (2.5.1) + method_source (1.0.0) minitest (4.7.5) - multi_json (1.8.4) - mustache (1.0.2) - rake (10.1.1) - rdiscount (2.1.8) - redcarpet (3.3.2) + multi_json (1.15.0) + mustache (1.1.1) + rake (13.0.6) + rdiscount (2.2.0.2) + redcarpet (3.5.1) rocco (0.8.2) mustache redcarpet @@ -44,28 +46,28 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) + sync (0.5.0) term-ansicolor (1.7.1) tins (~> 1.0) - thor (0.20.3) - thread_safe (0.1.3) - atomic - thread_safe (0.1.3-java) - atomic - tins (1.20.2) - tzinfo (0.3.38) + thor (1.1.0) + thread_safe (0.3.6) + tins (1.29.1) + sync + tzinfo (0.3.60) PLATFORMS - java ruby DEPENDENCIES activesupport + allocation_stats appraisal + benchmark-ips coveralls m! - minitest (= 4.7.5) + minitest (~> 4) rdiscount rocco BUNDLED WITH - 1.17.2 + 2.2.26 diff --git a/gemfiles/minitest5.gemfile b/gemfiles/minitest5.gemfile index 89bf298..f0ab5ba 100644 --- a/gemfiles/minitest5.gemfile +++ b/gemfiles/minitest5.gemfile @@ -2,7 +2,9 @@ source "https://rubygems.org" -gem "coveralls", :require => false, :group => :coverage -gem "minitest" +gem "coveralls", require: false +gem "benchmark-ips" +gem "allocation_stats" +gem "minitest", "~> 5" -gemspec :path => "../" +gemspec path: "../" diff --git a/gemfiles/minitest5.gemfile.lock b/gemfiles/minitest5.gemfile.lock index b71ffe5..9b50a28 100644 --- a/gemfiles/minitest5.gemfile.lock +++ b/gemfiles/minitest5.gemfile.lock @@ -8,29 +8,35 @@ PATH GEM remote: https://rubygems.org/ specs: - activesupport (3.2.16) - i18n (~> 0.6, >= 0.6.4) - multi_json (~> 1.0) - appraisal (0.5.2) + activesupport (6.1.4.1) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + allocation_stats (0.1.5) + appraisal (2.4.1) bundler rake + thor (>= 0.14.0) + benchmark-ips (2.9.1) + concurrent-ruby (1.1.9) coveralls (0.8.23) json (>= 1.8, < 3) simplecov (~> 0.16.1) term-ansicolor (~> 1.3) thor (>= 0.19.4, < 2.0) tins (~> 1.6) - docile (1.3.1) - i18n (0.6.9) - json (2.2.0) - json (2.2.0-java) - method_source (0.9.2) - minitest (5.3.1) - multi_json (1.8.4) - mustache (1.0.2) - rake (10.1.1) - rdiscount (2.1.8) - redcarpet (3.3.2) + docile (1.4.0) + i18n (1.8.10) + concurrent-ruby (~> 1.0) + json (2.5.1) + method_source (1.0.0) + minitest (5.14.4) + mustache (1.1.1) + rake (13.0.6) + rdiscount (2.2.0.2) + redcarpet (3.5.1) rocco (0.8.2) mustache redcarpet @@ -39,23 +45,29 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) + sync (0.5.0) term-ansicolor (1.7.1) tins (~> 1.0) - thor (0.20.3) - tins (1.20.2) + thor (1.1.0) + tins (1.29.1) + sync + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + zeitwerk (2.4.2) PLATFORMS - java ruby DEPENDENCIES activesupport + allocation_stats appraisal + benchmark-ips coveralls m! - minitest + minitest (~> 5) rdiscount rocco BUNDLED WITH - 1.17.2 + 2.2.26 diff --git a/gemfiles/test_unit_gem.gemfile b/gemfiles/test_unit_gem.gemfile index 2626400..5ac9a59 100644 --- a/gemfiles/test_unit_gem.gemfile +++ b/gemfiles/test_unit_gem.gemfile @@ -2,7 +2,9 @@ source "https://rubygems.org" -gem "coveralls", :require => false, :group => :coverage +gem "coveralls", require: false +gem "benchmark-ips" +gem "allocation_stats" gem "test-unit" -gemspec :path => "../" +gemspec path: "../" diff --git a/gemfiles/test_unit_gem.gemfile.lock b/gemfiles/test_unit_gem.gemfile.lock index 074b8a0..4601f26 100644 --- a/gemfiles/test_unit_gem.gemfile.lock +++ b/gemfiles/test_unit_gem.gemfile.lock @@ -8,33 +8,36 @@ PATH GEM remote: https://rubygems.org/ specs: - activesupport (4.2.3) - i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - appraisal (2.0.2) + activesupport (6.1.4.1) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + allocation_stats (0.1.5) + appraisal (2.4.1) bundler rake thor (>= 0.14.0) + benchmark-ips (2.9.1) + concurrent-ruby (1.1.9) coveralls (0.8.23) json (>= 1.8, < 3) simplecov (~> 0.16.1) term-ansicolor (~> 1.3) thor (>= 0.19.4, < 2.0) tins (~> 1.6) - docile (1.3.1) - i18n (0.7.0) - json (1.8.6) - json (1.8.6-java) - method_source (0.9.2) - minitest (5.7.0) - mustache (1.0.2) - power_assert (0.2.4) - rake (10.4.2) - rdiscount (2.1.8) - redcarpet (3.3.2) + docile (1.4.0) + i18n (1.8.10) + concurrent-ruby (~> 1.0) + json (2.5.1) + method_source (1.0.0) + minitest (5.14.4) + mustache (1.1.1) + power_assert (2.0.1) + rake (13.0.6) + rdiscount (2.2.0.2) + redcarpet (3.5.1) rocco (0.8.2) mustache redcarpet @@ -43,24 +46,26 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) + sync (0.5.0) term-ansicolor (1.7.1) tins (~> 1.0) - test-unit (3.1.2) + test-unit (3.4.4) power_assert - thor (0.20.3) - thread_safe (0.3.5) - thread_safe (0.3.5-java) - tins (1.20.2) - tzinfo (1.2.2) - thread_safe (~> 0.1) + thor (1.1.0) + tins (1.29.1) + sync + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + zeitwerk (2.4.2) PLATFORMS - java ruby DEPENDENCIES activesupport + allocation_stats appraisal + benchmark-ips coveralls m! rdiscount @@ -68,4 +73,4 @@ DEPENDENCIES test-unit BUNDLED WITH - 1.17.2 + 2.2.26 diff --git a/lib/m/frameworks.rb b/lib/m/frameworks.rb index 8ff9d57..e690ba7 100644 --- a/lib/m/frameworks.rb +++ b/lib/m/frameworks.rb @@ -30,12 +30,16 @@ def test_unit? self.class.test_unit? end + def self.minitest_version_major + defined?(Minitest) ? Minitest::Unit::VERSION.slice(/\d+/) : nil + end + def self.minitest5? - defined?(Minitest) && Minitest::Unit::VERSION.start_with?("5") + minitest_version_major == "5" end def self.minitest4? - defined?(MiniTest) + minitest_version_major == "4" end def self.test_unit? diff --git a/test/active_support_test.rb b/test/active_support_test.rb index 889feb0..9677606 100644 --- a/test/active_support_test.rb +++ b/test/active_support_test.rb @@ -2,28 +2,28 @@ class ActiveSupportTest < MTest def test_run_simple_test_by_line_number - output = m('examples/active_support_example_test.rb:11') - assert_output(/1 tests, 1 assertions/, output) + output = m('examples/active_support_example_test.rb:12') + assert_output(/1 (runs|tests), 1 assertions/, output) end def test_runs_entire_test_without_line_number output = m('examples/active_support_example_test.rb') - assert_output(/4 tests/, output) + assert_output(/4 (runs|tests)/, output) end def test_run_inside_of_test - output = m('examples/active_support_example_test.rb:12') - assert_output(/1 tests, 1 assertions/, output) + output = m('examples/active_support_example_test.rb:13') + assert_output(/1 (runs|tests), 1 assertions/, output) end def test_run_on_end_of_test - output = m('examples/active_support_example_test.rb:13') - assert_output(/1 tests, 1 assertions/, output) + output = m('examples/active_support_example_test.rb:14') + assert_output(/1 (runs|tests), 1 assertions/, output) end def test_run_inside_big_test - output = m('examples/active_support_example_test.rb:17') - assert_output(/1 tests, 3 assertions/, output) + output = m('examples/active_support_example_test.rb:18') + assert_output(/1 (runs|tests), 3 assertions/, output) end def test_run_on_blank_line_orders_tests_by_line_number @@ -33,21 +33,21 @@ def test_run_on_blank_line_orders_tests_by_line_number expected = <<-EOF No tests found on line 2. Valid tests to run: - test_normal: m examples/active_support_example_test.rb:7 - test_carrot: m examples/active_support_example_test.rb:11 - test_daikon: m examples/active_support_example_test.rb:15 -test_eggplant_fig: m examples/active_support_example_test.rb:21 + test_normal: m examples/active_support_example_test.rb:8 + test_carrot: m examples/active_support_example_test.rb:12 + test_daikon: m examples/active_support_example_test.rb:16 +test_eggplant_fig: m examples/active_support_example_test.rb:22 EOF assert_equal expected.strip, output end def test_run_on_test_with_spaces - output = m('examples/active_support_example_test.rb:21') - assert_output(/1 tests, 1 assertions/, output) + output = m('examples/active_support_example_test.rb:22') + assert_output(/1 (runs|tests), 1 assertions/, output) end def test_run_on_test_with_unescaped_regular_express_characters - output = m('examples/active_support_unescaped_example_test.rb:7') - assert_output(/1 tests, 1 assertions/, output) + output = m('examples/active_support_unescaped_example_test.rb:8') + assert_output(/1 (runs|tests), 1 assertions/, output) end end diff --git a/test/everything_test.rb b/test/everything_test.rb index d6d17f2..5b0dea8 100644 --- a/test/everything_test.rb +++ b/test/everything_test.rb @@ -3,7 +3,7 @@ class EverythingTest < MTest def test_runs_entire_test_suite_with_no_arguments output = m('') - assert_output(/12 tests/, output) + assert_output(/12 (runs|tests)/, output) end def test_missing_file_gives_a_decent_error_message @@ -19,15 +19,15 @@ def test_missing_file_gives_a_decent_error_message def test_running_tests_within_a_subdirectory output = m('examples/subdir') - assert_output(/3 tests/, output) + assert_output(/3 (runs|tests)/, output) output = m('examples') - assert_output(/12 tests/, output) + assert_output(/12 (runs|tests)/, output) end def test_running_tests_with_failures_within_a_subdirectory output = m('examples/subdir_with_failures') - assert_output_for_failed_execution(/1 tests, 1 assertions, 1 failures/, output) + assert_output_for_failed_execution(/1 (runs|tests), 1 assertions, 1 failures/, output) end def test_blank_file_is_quieter diff --git a/test/examples/active_support_example_test.rb b/test/examples/active_support_example_test.rb index 1320c25..3da0385 100644 --- a/test/examples/active_support_example_test.rb +++ b/test/examples/active_support_example_test.rb @@ -1,3 +1,4 @@ +require 'active_support' require 'active_support/test_case' class ActiveSupportExampleTest < ActiveSupport::TestCase diff --git a/test/examples/active_support_unescaped_example_test.rb b/test/examples/active_support_unescaped_example_test.rb index 659f125..aa43c24 100644 --- a/test/examples/active_support_unescaped_example_test.rb +++ b/test/examples/active_support_unescaped_example_test.rb @@ -1,3 +1,4 @@ +require 'active_support' require 'active_support/test_case' class ActiveSupportExampleTest < ActiveSupport::TestCase diff --git a/test/examples/minitest_example_test.rb b/test/examples/minitest_example_test.rb new file mode 100644 index 0000000..95f5af3 --- /dev/null +++ b/test/examples/minitest_example_test.rb @@ -0,0 +1,36 @@ +require 'minitest/unit' + +class Meme + def i_can_has_cheezburger? + "OHAI!" + end + + def will_it_blend? + "YES!" + end +end + +Test = M::Frameworks.minitest4? ? MiniTest::Unit::TestCase : Minitest::Test + +class TestMeme < Test + def setup + @meme = Meme.new + end + + def test_that_kitty_can_eat + assert_equal "OHAI!", @meme.i_can_has_cheezburger? + end + + def test_that_it_will_not_blend + refute_match(/^maybe/i, @meme.will_it_blend?) + refute_match(/^no/i, @meme.will_it_blend?) + refute_match(/^lolz/i, @meme.will_it_blend?) + end + + def test_that_kitty_can_eat_two_time + assert_equal "OHAI!", @meme.i_can_has_cheezburger? + assert_equal "OHAI!", @meme.i_can_has_cheezburger? + end + + Minitest.after_run { p "ran after run block" } if Minitest.respond_to?(:after_run) +end diff --git a/test/examples/multiple_example_test.rb b/test/examples/multiple_example_test.rb index 53afa6d..a0e9c62 100644 --- a/test/examples/multiple_example_test.rb +++ b/test/examples/multiple_example_test.rb @@ -1,3 +1,4 @@ +require 'active_support' require 'active_support/test_case' class MultipleExampleTest < ActiveSupport::TestCase diff --git a/test/multiple_test.rb b/test/multiple_test.rb index 16e95fb..4aa65e0 100644 --- a/test/multiple_test.rb +++ b/test/multiple_test.rb @@ -3,16 +3,16 @@ class MultipleTest < MTest def test_run_simple_test_by_line_number output = m('examples/multiple_example_test.rb:11') - assert_output(/1 tests, 1 assertions/, output) + assert_output(/1 (runs|tests), 1 assertions/, output) end def test_runs_entire_test_without_line_number output = m('examples/multiple_example_test.rb') - assert_output(/4 tests/, output) + assert_output(/4 (runs|tests)/, output) end def test_runs_all_tests_on_given_line_number output = m('examples/multiple_example_test.rb:6') - assert_output(/3 tests/, output) + assert_output(/3 (runs|tests)/, output) end end diff --git a/test/options_test.rb b/test/options_test.rb index 513745d..124a285 100644 --- a/test/options_test.rb +++ b/test/options_test.rb @@ -17,23 +17,23 @@ def test_verbose_option end def test_short_line_option - output = m('-l20 examples/minitest_4_example_test.rb') - assert_output(/1 tests, 1 assertions/, output) + output = m('-l20 examples/minitest_example_test.rb') + assert_output(/1 (runs|tests), 1 assertions/, output) end def test_long_line_option - output = m('--line 20 examples/minitest_4_example_test.rb') - assert_output(/1 tests, 1 assertions/, output) + output = m('--line 20 examples/minitest_example_test.rb') + assert_output(/1 (runs|tests), 1 assertions/, output) end def test_line_option_has_precedence_over_colon_format - output = m('--line 20 examples/minitest_4_example_test.rb:2') - assert_output(/1 tests, 1 assertions/, output) + output = m('--line 20 examples/minitest_example_test.rb:2') + assert_output(/1 (runs|tests), 1 assertions/, output) end def test_recursive_option output = m('-r examples/subdir') - assert_output(/5 tests/, output) + assert_output(/5 (runs|tests)/, output) end def test_recursive_option_without_directory_arg_fails @@ -46,13 +46,20 @@ def test_passthrough_options assert_output(/0 errors/, output) end + def test_passthrough_options_name_with_file + output = m('examples/minitest_example_test.rb -- --name /test_that_it_will_not_blend/') + assert_output(/1 (runs|tests)/, output) + assert_output(/0 failures/, output) + assert_output(/0 errors/, output) + end + def test_passthrough_options_with_file - output = m('examples/minitest_4_example_test.rb -- --verbose') - assert_output(/3 tests, 9 assertions/, output) + output = m('examples/minitest_example_test.rb -- --verbose') + assert_output(/3 (runs|tests), 9 assertions/, output) end def test_passthrough_options_with_file_and_other_options - output = m('--line 20 examples/minitest_4_example_test.rb -- --verbose') - assert_output(/1 tests, 1 assertions/, output) + output = m('--line 20 examples/minitest_example_test.rb -- --verbose') + assert_output(/1 (runs|tests), 1 assertions/, output) end end