[#4076] Ruby/DL — Jamis Buck <jamis_buck@...>

I recently used Ruby/DL to create bindings to the SQLite3 embedded

40 messages 2005/01/03
[#4096] Re: Ruby/DL — Paul Brannan <pbrannan@...> 2005/01/04

On Tue, Jan 04, 2005 at 02:53:49AM +0900, Jamis Buck wrote:

[#4099] Re: Ruby/DL — ts <decoux@...> 2005/01/04

>>>>> "P" == Paul Brannan <pbrannan@atdesk.com> writes:

[#4119] Re: Ruby/DL — Paul Brannan <pbrannan@...> 2005/01/05

On Wed, Jan 05, 2005 at 03:05:48AM +0900, ts wrote:

[#4120] Re: Ruby/DL — ts <decoux@...> 2005/01/05

>>>>> "P" == Paul Brannan <pbrannan@atdesk.com> writes:

[#4125] Re: Ruby/DL — Paul Brannan <pbrannan@...> 2005/01/05

On Thu, Jan 06, 2005 at 01:10:34AM +0900, ts wrote:

[#4116] Test::Unit::Collector::Dir won't work with code that modifies $LOAD_PATH — Eric Hodel <drbrain@...7.net>

Any test code that depends upon modifications of $: fails when used

10 messages 2005/01/05

[#4146] The face of Unicode support in the future — Charles O Nutter <headius@...>

Hello Rubyists!

47 messages 2005/01/06
[#4152] Re: The face of Unicode support in the future — Yukihiro Matsumoto <matz@...> 2005/01/07

Hi,

[#4167] Re: The face of Unicode support in the future — Christian Neukirchen <chneukirchen@...> 2005/01/09

Yukihiro Matsumoto <matz@ruby-lang.org> writes:

[#4175] Re: The face of Unicode support in the future — Yukihiro Matsumoto <matz@...> 2005/01/10

Hi,

[#4186] Re: The face of Unicode support in the future — Paul Brannan <pbrannan@...> 2005/01/11

On Mon, Jan 10, 2005 at 11:53:48PM +0900, Yukihiro Matsumoto wrote:

[#4192] Re: The face of Unicode support in the future — Yukihiro Matsumoto <matz@...> 2005/01/12

Hi,

[#4269] Re: The face of Unicode support in the future — Wes Nakamura <wknaka@...>

19 messages 2005/01/18
[#4270] Re: The face of Unicode support in the future — Yukihiro Matsumoto <matz@...> 2005/01/18

Hi,

[#4275] Re: The face of Unicode support in the future — Wes Nakamura <wknaka@...> 2005/01/19

[#4323] test/unit doesn't rescue a Exception — Tanaka Akira <akr@...17n.org>

test/unit doesn't rescue a Exception in a test method, as follows.

14 messages 2005/01/27
[#8773] Re: test/unit doesn't rescue a Exception — Tanaka Akira <akr@...> 2006/09/02

In article <87is5jb46q.fsf@serein.a02.aist.go.jp>,

[#8776] Re: test/unit doesn't rescue a Exception — "Nathaniel Talbott" <ntalbott@...> 2006/09/03

On 9/1/06, Tanaka Akira <akr@fsij.org> wrote:

[#8777] Re: test/unit doesn't rescue a Exception — Eric Hodel <drbrain@...7.net> 2006/09/03

On Sep 2, 2006, at 6:34 PM, Nathaniel Talbott wrote:

Re: Test::Unit::Collector::Dir won't work with code that modifies $LOAD_PATH

From: Nathaniel Talbott <ntalbott@...>
Date: 2005-01-27 22:17:27 UTC
List: ruby-core #4325
On Fri, 14 Jan 2005 23:48:58 -0500, Nathaniel Talbott
<ntalbott@gmail.com> wrote:

> Again, I am looking at it and hope to have a fix by next weekend at the latest.
> 
> Thanks for your patience,

Well, I'm a little late, but here's my proposed patch. Note that it
*doesn't* fix the dir collector's trashing of the $LOAD_PATH; rather,
it re-introduces the functionality lost in 1.8.2, allowing you to do
this:

  ruby -rtest/unit -rtest1 -rtest2 -e0

And have the objectspace collector used.

I also messed around with the semantics of calling AutoRunner.run, and
I'd like to have some more eyeballs look it over and test it before I
release it, as I know I'm not hitting all of the use cases (for testrb
and test/runner.rb in particular).

As for fixing the dir collector so that it respects the $LOAD_PATH,
I'm not happy with the robustness of the solutions I've found so far.
The best solution would be to find a way to not modify $LOAD_PATH at
all, but I'm not sure if that's possible. Otherwise I'm stuck trying
to undo only the changes made for requiring a test file, but I don't
think there's a completely fool-proof way of doing that, and I'm
afraid of introducing weird corner-cases that look like they ought to
work but don't. Ideas?

Any feedback on the patch is welcome... I will aim to commit it this weekend.

Thanks,


-- 
Nathaniel

<:((><
Terralien, Inc.

Attachments (1)

patch.txt (5.08 KB, text/x-diff)
Index: ChangeLog
===================================================================
RCS file: /var/cvs/src/ruby/ChangeLog,v
retrieving revision 1.2673.2.810
diff -u -r1.2673.2.810 ChangeLog
--- ChangeLog	26 Jan 2005 15:16:05 -0000	1.2673.2.810
+++ ChangeLog	27 Jan 2005 21:36:58 -0000
@@ -1,3 +1,13 @@
+Fri Jan 28 06:20:00 2005  Nathaniel Talbott  <ntalbott@ruby-lang.org>
+
+  * lib/test/unit/autorunner.rb (AutoRunner.run): fixed so that
+    'ruby -rtest/unit -rtest1 -rtest2 -e0' will use the objectspace
+    collector again. Also tried to simplify the calling convention.
+    
+  * test/runner.rb: adjusted for new AutoRunner semantics.
+  
+  * lib/test/unit.rb: ditto.
+
 Thu Jan 27 00:15:29 2005  Minero Aoki  <aamine@loveruby.net>
 
 	* test/fileutils/test_fileutils.rb (setup): support BSD-style
Index: lib/test/unit.rb
===================================================================
RCS file: /var/cvs/src/ruby/lib/test/unit.rb,v
retrieving revision 1.7.2.5
diff -u -r1.7.2.5 unit.rb
--- lib/test/unit.rb	19 Dec 2004 02:01:58 -0000	1.7.2.5
+++ lib/test/unit.rb	27 Jan 2005 21:36:59 -0000
@@ -240,35 +240,35 @@
   #  class TS_MyTests
   #    def self.suite
   #      suite = Test::Unit::TestSuite.new
-#      suite << TC_MyFirstTests.suite
-#      suite << TC_MoreTestsByMe.suite
-#      suite << TS_AnotherSetOfTests.suite
-#      return suite
-#    end
-#  end
-#  Test::Unit::UI::Console::TestRunner.run(TS_MyTests)
-#
-# Now, this is a bit cumbersome, so Test::Unit does a little bit more
-# for you, by wrapping these up automatically when you require
-# 'test/unit'. What does this mean? It means you could write the above
-# test case like this instead:
-#
-#  require 'test/unit'
-#  require 'tc_myfirsttests'
-#  require 'tc_moretestsbyme'
-#  require 'ts_anothersetoftests'
-#
-# Test::Unit is smart enough to find all the test cases existing in
-# the ObjectSpace and wrap them up into a suite for you. It then runs
-# the dynamic suite using the console TestRunner.
-#
-#
-# == Questions?
-#
-# I'd really like to get feedback from all levels of Ruby
-# practitioners about typos, grammatical errors, unclear statements,
-# missing points, etc., in this document (or any other).
-#
+  #      suite << TC_MyFirstTests.suite
+  #      suite << TC_MoreTestsByMe.suite
+  #      suite << TS_AnotherSetOfTests.suite
+  #      return suite
+  #    end
+  #  end
+  #  Test::Unit::UI::Console::TestRunner.run(TS_MyTests)
+  #
+  # Now, this is a bit cumbersome, so Test::Unit does a little bit more
+  # for you, by wrapping these up automatically when you require
+  # 'test/unit'. What does this mean? It means you could write the above
+  # test case like this instead:
+  #
+  #  require 'test/unit'
+  #  require 'tc_myfirsttests'
+  #  require 'tc_moretestsbyme'
+  #  require 'ts_anothersetoftests'
+  #
+  # Test::Unit is smart enough to find all the test cases existing in
+  # the ObjectSpace and wrap them up into a suite for you. It then runs
+  # the dynamic suite using the console TestRunner.
+  #
+  #
+  # == Questions?
+  #
+  # I'd really like to get feedback from all levels of Ruby
+  # practitioners about typos, grammatical errors, unclear statements,
+  # missing points, etc., in this document (or any other).
+  #
   module Unit
     def self.run=(flag)
       @run = flag
@@ -282,6 +282,6 @@
 
 at_exit do
   unless $! || Test::Unit.run?
-    exit Test::Unit::AutoRunner.run($0 != "-e" && $0)
+    exit Test::Unit::AutoRunner.run
   end
 end
Index: lib/test/unit/autorunner.rb
===================================================================
RCS file: /var/cvs/src/ruby/lib/test/unit/autorunner.rb,v
retrieving revision 1.8.2.2
diff -u -r1.8.2.2 autorunner.rb
--- lib/test/unit/autorunner.rb	19 Dec 2004 02:01:58 -0000	1.8.2.2
+++ lib/test/unit/autorunner.rb	27 Jan 2005 21:36:59 -0000
@@ -5,14 +5,20 @@
 module Test
   module Unit
     class AutoRunner
-      def self.run(current_file=nil, default_dir=nil, argv=ARGV, &block)
-        if(!current_file || current_file == $0)
-          r = new(!current_file, &block)
-          if !r.process_args(argv) && default_dir
-            r.to_run << default_dir
-          end
-          r.run
+      def self.run(force_standalone=false, default_dir=nil, argv=ARGV, &block)
+        r = new(force_standalone || standalone?, &block)
+        if((!r.process_args(argv)) && default_dir)
+          r.to_run << default_dir
         end
+        r.run
+      end
+      
+      def self.standalone?
+        return false unless("-e" == $0)
+        ObjectSpace.each_object(Class) do |klass|
+          return false if(klass < TestCase)
+        end
+        true
       end
 
       RUNNERS = {
Index: test/runner.rb
===================================================================
RCS file: /var/cvs/src/ruby/test/runner.rb,v
retrieving revision 1.11
diff -u -r1.11 runner.rb
--- test/runner.rb	2 Dec 2003 12:31:44 -0000	1.11
+++ test/runner.rb	27 Jan 2005 21:36:59 -0000
@@ -4,4 +4,4 @@
 Version = rcsid[2].scan(/\d+/).collect!(&method(:Integer)).freeze
 Release = rcsid[3].freeze
 
-exit Test::Unit::AutoRunner.run(false, File.dirname($0))
+exit Test::Unit::AutoRunner.run(true, File.dirname($0))


In This Thread