Project

General

Profile

Actions

Bug #9660

closed

test/unit, minitest & bundler

Added by marcandre (Marc-Andre Lafortune) about 10 years ago. Updated over 9 years ago.

Status:
Closed
Target version:
ruby -v:
r45033
[ruby-core:61623]

Description

test/unit now calls gem 'minitest', but this will create regressions for anyone using bundler.

For example, create an empty Gemfile and try bundle exec ruby -e "require 'test/unit'"

You get an error:

.rvm/gems/ruby-head@global/gems/bundler-1.5.3/lib/bundler/rubygems_integration.rb:240:in `block in replace_gem': minitest is not part of the bundle. Add it to Gemfile. (Gem::LoadError)

See: https://github.com/ruby/ruby/commit/da61291a25faae95f33de6756b2eaa4804d5ef2b#commitcomment-5761129


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #9711: Remove test-unit and minitest from stdlib.Closedzenspider (Ryan Davis)04/07/2014Actions

Updated by sorah (Sorah Fukumori) about 10 years ago

I guess this ugly patch fixes problem, but I want to find better solutions...

diff --git a/lib/test/unit.rb b/lib/test/unit.rb
index ccfe1ce..eb7545b 100644
--- a/lib/test/unit.rb
+++ b/lib/test/unit.rb
@@ -1,5 +1,25 @@
-gem 'minitest', '< 5.0.0' if defined? Gem
+if defined? Gem
+  begin
+    gem 'minitest', '< 5.0.0'
+  rescue Gem::LoadError # for bundler
+  end
+end
+
 require 'minitest/unit'
+
+if '5.0.0' <= MiniTest::Unit::VERSION
+  module Test
+    module Unit
+      class CompatibilityError < Exception
+      end
+    end
+  end
+
+  raise Test::Unit::CompatibilityError,
+    "test/unit only works on MiniTest 4 " \
+    "(MiniTest #{MiniTest::Unit::VERSION} loaded)"
+end
+
 require 'test/unit/assertions'
 require 'test/unit/testcase'
 require 'optparse'

Updated by hsbt (Hiroshi SHIBATA) almost 10 years ago

I think bundled test-unit should be rename like rbunit or ruby-unit. many of users is confused by bundled test-unit and test-unit gem.
If we can't merge their, it should be renamed.

Updated by zzak (zzak _) almost 10 years ago

I like the name ruby-unit, in this case we should also consider changing the namespaces to match (ie: RubyUnit)

Updated by normalperson (Eric Wong) almost 10 years ago

wrote:

I like the name ruby-unit, in this case we should also consider
changing the namespaces to match (ie: RubyUnit)

Might as well use Minitest:: at that point, right?

Updated by normalperson (Eric Wong) almost 10 years ago

wrote:

wrote:

I like the name ruby-unit, in this case we should also consider
changing the namespaces to match (ie: RubyUnit)

Might as well use Minitest:: at that point, right?

Nevermind, there's a lot of old assertions which Minitest drops.
Maybe we can do it long term.

Updated by robin850 (Robin Dupret) almost 10 years ago

Hello,

I take the liberty to link to a branch with a beginning of patch that updates the bundled version of Minitest to 5 (https://github.com/robin850/ruby/compare/minitest-five) since this is more or less related to the problem here. IMO, this is really bad to have a "deprecated"/out dated version of a library that you're shipping with by default. I'm conscious that the amount of work would be pretty important to rename all Test::Unit::TestCase classes to Minitest::Test but the wrapper is not so nice.

Moreover, I don't think the amount of work needed to rename the test suite is really worth regarding the final result. The test cases would have to be renamed anyway if we follow Zachary's suggestion (which is legit, I think ; it would make no sense to have a ruby/unit.rb file with a Test::Unit class in it).

I find it sometimes annoying to have to create a Gemfile adding gem 'minitest' in it just to use an up to date version of Minitest.

I'm pretty sure you have good reasons to stuck with Test::Unit inside your test suite, but just my two cents here.

Have a nice day.

Updated by wanabe (_ wanabe) almost 10 years ago

  • Related to Feature #9711: Remove test-unit and minitest from stdlib. added

Updated by hsbt (Hiroshi SHIBATA) over 9 years ago

  • Status changed from Open to Closed
  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED

fixed at r45970

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0