Project

General

Profile

Bug #3972

r28668 breaks test/unit when combined with the testing rake task

Added by tenderlovemaking (Aaron Patterson) about 10 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
-
Backport:
[ruby-core:32864]

Description

=begin
r28668 makes Test::Unit process command line arguments even when used in conjunction with the rake test loader. This causes every test file to be required twice.

How to reproduce:

  1. Create a file "foo.rb" with a test:

require 'test/unit'

puts "HELLO!"

class Foo < Test::Unit::TestCase
def test_whatever
assert true
end
end

  1. Run the test using the rake test loader like this:

$ ruby -w "/Users/apatterson/.local/lib/ruby/1.9.1/rake/rake_test_loader.rb" "foo.rb"

You'll see "HELLO!" printed twice and warnings about methods being redefined.

Here is a video of the failure:

http://www.youtube.com/watch?v=woj1IYnEZdA
=end


Files

noname (500 Bytes) noname tenderlovemaking (Aaron Patterson), 02/24/2011 05:23 AM
noname (500 Bytes) noname tenderlovemaking (Aaron Patterson), 04/12/2011 08:17 PM
noname (500 Bytes) noname tenderlovemaking (Aaron Patterson), 04/12/2011 08:18 PM
#1

Updated by Anonymous about 10 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r29577.
Aaron, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

#2

Updated by tenderlovemaking (Aaron Patterson) over 9 years ago

  • Status changed from Closed to Open
  • ruby -v changed from ruby 1.9.3dev (2010-10-18 trunk 29530) [x86_64-darwin10.4.0] to ruby 1.9.3dev (2011-02-18 trunk 30894) [x86_64-darwin10.6.0]

=begin
r30849 causes this bug again. Please revert r30849 or stop including include Test::Unit::RequireFiles in class Runner.
=end

#3

Updated by Anonymous over 9 years ago

  • Status changed from Open to Closed

=begin
This issue was solved with changeset r30913.
Aaron, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • lib/test/unit.rb: partial revert of r30849. [ruby-core:32864]
  • test/testunit/test_rake_integration.rb: adding an integration test with the rake loader to prevent regressions. =end
#4

Updated by nagachika (Tomoyuki Chikanaga) over 9 years ago

=begin
Hi,

After r30913, make test-all output warning and testunit message in test_rake_integration.rb like follows.

.../path/to/src/lib/test/unit.rb:43: warning: instance variable @options not initialized
Run options:

# Running tests:

Finished tests in 0.000475s, 0.0000 tests/s, 0.0000 assertions/s.

0 tests, 0 assertions, 0 failures, 0 errors, 0 skips
.....

Aaron san, What do you think about the following patch? Is it OK to @options = nil in Options#initialize?

diff --git a/lib/test/unit.rb b/lib/test/unit.rb
index 1272153..49c4e51 100644
--- a/lib/test/unit.rb
+++ b/lib/test/unit.rb
@@ -32,6 +32,7 @@ module Test
module Options
def initialize(*, &block)
@init_hook = block

  • @options = nil super(&nil) end

diff --git a/test/testunit/test_rake_integration.rb b/test/testunit/test_rake_integration.rb
index bb0951d..86a0cf8 100644
--- a/test/testunit/test_rake_integration.rb
+++ b/test/testunit/test_rake_integration.rb
@@ -24,7 +24,12 @@ class FooTest; end
eotest
end

  • assert_ruby_status(%w{ -w } + [RAKE_LOADER, filename])
  • args = %w{ -w } + [RAKE_LOADER, filename]
  • bug3972 = "[ruby-core:32864]"
  • status = assert_in_out_err(args, "",
  • /0 tests, 0 assertions, 0 failures, 0 errors, 0 skips/,
  • [], bug3972)
  • assert_equal(true, status.success?, bug3972) end end end

=end

Updated by tenderlovemaking (Aaron Patterson) over 9 years ago

  • ruby -v changed from ruby 1.9.3dev (2011-02-18 trunk 30894) [x86_64-darwin10.6.0] to -

=begin
On Tue, Feb 22, 2011 at 11:39:20PM +0900, Tomoyuki Chikanaga wrote:

Issue #3972 has been updated by Tomoyuki Chikanaga.

Hi,

After r30913, make test-all output warning and testunit message in test_rake_integration.rb like follows.

.../path/to/src/lib/test/unit.rb:43: warning: instance variable @options not initialized
Run options:

Running tests:

Finished tests in 0.000475s, 0.0000 tests/s, 0.0000 assertions/s.

0 tests, 0 assertions, 0 failures, 0 errors, 0 skips
.....

Aaron san, What do you think about the following patch? Is it OK to @options = nil in Options#initialize?

diff --git a/lib/test/unit.rb b/lib/test/unit.rb
index 1272153..49c4e51 100644
--- a/lib/test/unit.rb
+++ b/lib/test/unit.rb
@@ -32,6 +32,7 @@ module Test
module Options
def initialize(*, &block)
@init_hook = block

  • @options = nil super(&nil) end

diff --git a/test/testunit/test_rake_integration.rb b/test/testunit/test_rake_integration.rb
index bb0951d..86a0cf8 100644
--- a/test/testunit/test_rake_integration.rb
+++ b/test/testunit/test_rake_integration.rb
@@ -24,7 +24,12 @@ class FooTest; end
eotest
end

  • assert_ruby_status(%w{ -w } + [RAKE_LOADER, filename])
  • args = %w{ -w } + [RAKE_LOADER, filename]
  • bug3972 = "[ruby-core:32864]"
  • status = assert_in_out_err(args, "",
  • /0 tests, 0 assertions, 0 failures, 0 errors, 0 skips/,
  • [], bug3972)
  • assert_equal(true, status.success?, bug3972) end end end

This patch seems good to me. This warning annoys me too so I'll apply
the patch (if all tests pass). :-)

--
Aaron Patterson
http://tenderlovemaking.com/
=end

Updated by nagachika (Tomoyuki Chikanaga) over 9 years ago

=begin
Thank you for your reviewing. :)
I'll check in it by myself after check test.
=end

Updated by tenderlovemaking (Aaron Patterson) over 9 years ago

=begin
On Tue, Feb 22, 2011 at 11:39:20PM +0900, Tomoyuki Chikanaga wrote:

Issue #3972 has been updated by Tomoyuki Chikanaga.

Hi,

After r30913, make test-all output warning and testunit message in test_rake_integration.rb like follows.

.../path/to/src/lib/test/unit.rb:43: warning: instance variable @options not initialized
Run options:

Running tests:

Finished tests in 0.000475s, 0.0000 tests/s, 0.0000 assertions/s.

0 tests, 0 assertions, 0 failures, 0 errors, 0 skips
.....

Aaron san, What do you think about the following patch? Is it OK to @options = nil in Options#initialize?

diff --git a/lib/test/unit.rb b/lib/test/unit.rb
index 1272153..49c4e51 100644
--- a/lib/test/unit.rb
+++ b/lib/test/unit.rb
@@ -32,6 +32,7 @@ module Test
module Options
def initialize(*, &block)
@init_hook = block

  • @options = nil super(&nil) end

diff --git a/test/testunit/test_rake_integration.rb b/test/testunit/test_rake_integration.rb
index bb0951d..86a0cf8 100644
--- a/test/testunit/test_rake_integration.rb
+++ b/test/testunit/test_rake_integration.rb
@@ -24,7 +24,12 @@ class FooTest; end
eotest
end

  • assert_ruby_status(%w{ -w } + [RAKE_LOADER, filename])
  • args = %w{ -w } + [RAKE_LOADER, filename]
  • bug3972 = "[ruby-core:32864]"
  • status = assert_in_out_err(args, "",
  • /0 tests, 0 assertions, 0 failures, 0 errors, 0 skips/,
  • [], bug3972)
  • assert_equal(true, status.success?, bug3972) end end end

This patch seems good to me. This warning annoys me too so I'll apply
the patch (if all tests pass). :-)

--
Aaron Patterson
http://tenderlovemaking.com/
=end

Updated by tenderlovemaking (Aaron Patterson) over 9 years ago

=begin
On Tue, Feb 22, 2011 at 11:39:20PM +0900, Tomoyuki Chikanaga wrote:

Issue #3972 has been updated by Tomoyuki Chikanaga.

Hi,

After r30913, make test-all output warning and testunit message in test_rake_integration.rb like follows.

.../path/to/src/lib/test/unit.rb:43: warning: instance variable @options not initialized
Run options:

Running tests:

Finished tests in 0.000475s, 0.0000 tests/s, 0.0000 assertions/s.

0 tests, 0 assertions, 0 failures, 0 errors, 0 skips
.....

Aaron san, What do you think about the following patch? Is it OK to @options = nil in Options#initialize?

diff --git a/lib/test/unit.rb b/lib/test/unit.rb
index 1272153..49c4e51 100644
--- a/lib/test/unit.rb
+++ b/lib/test/unit.rb
@@ -32,6 +32,7 @@ module Test
module Options
def initialize(*, &block)
@init_hook = block

  • @options = nil super(&nil) end

diff --git a/test/testunit/test_rake_integration.rb b/test/testunit/test_rake_integration.rb
index bb0951d..86a0cf8 100644
--- a/test/testunit/test_rake_integration.rb
+++ b/test/testunit/test_rake_integration.rb
@@ -24,7 +24,12 @@ class FooTest; end
eotest
end

  • assert_ruby_status(%w{ -w } + [RAKE_LOADER, filename])
  • args = %w{ -w } + [RAKE_LOADER, filename]
  • bug3972 = "[ruby-core:32864]"
  • status = assert_in_out_err(args, "",
  • /0 tests, 0 assertions, 0 failures, 0 errors, 0 skips/,
  • [], bug3972)
  • assert_equal(true, status.success?, bug3972) end end end

This patch seems good to me. This warning annoys me too so I'll apply
the patch (if all tests pass). :-)

--
Aaron Patterson
http://tenderlovemaking.com/
=end

Also available in: Atom PDF