--Apple-Mail-58--96760417
Content-Type: multipart/mixed; boundary=Apple-Mail-57--96760441


--Apple-Mail-57--96760441
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed

Any test code that depends upon modifications of $: fails when used 
with test/unit's directory collector.

I discovered this with Rake 0.4.15 (which uses testrb, which invokes 
the directory collector) and Rails.

The dir collector dups $:, then in an ensure, replaces $: with the 
dup'd copy, undoing any changes of $: inside the dir collector.  I have 
two proposed patches, one that deletes only the temporary addition to 
$:, and one that does not delete the temporary addition.

I prefer the "$:.delete_at $:.rindex(dir)" cleanup patch, I think it 
has fewer unintended consequences for the user.


--Apple-Mail-57--96760441
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
	x-unix-mode=0644;
	name="dir.rb.dont_cleanup.patch"
Content-Disposition: attachment;
	filename=dir.rb.dont_cleanup.patch

Index: lib/test/unit/collector/dir.rb
===================================================================
RCS file: /src/ruby/lib/test/unit/collector/dir.rb,v
retrieving revision 1.4.2.1
diff -u -r1.4.2.1 dir.rb
--- lib/test/unit/collector/dir.rb	19 Dec 2004 02:01:59 -0000	1.4.2.1
+++ lib/test/unit/collector/dir.rb	5 Jan 2005 02:24:17 -0000
@@ -75,7 +75,6 @@
         end
 
         def collect_file(name, suites, already_gathered)
-          loadpath = $:.dup
           dir = File.dirname(File.expand_path(name))
           $:.unshift(dir) unless $:.first == dir
           if(@req)
@@ -84,8 +83,6 @@
             require(name)
           end
           find_test_cases(already_gathered).each{|t| add_suite(suites, t.suite)}
-        ensure
-          $:.replace(loadpath)
         end
       end
     end

--Apple-Mail-57--96760441
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
	x-unix-mode=0644;
	name="dir.rb.cleanup.patch"
Content-Disposition: attachment;
	filename=dir.rb.cleanup.patch

Index: lib/test/unit/collector/dir.rb
===================================================================
RCS file: /src/ruby/lib/test/unit/collector/dir.rb,v
retrieving revision 1.4.2.1
diff -u -r1.4.2.1 dir.rb
--- lib/test/unit/collector/dir.rb	19 Dec 2004 02:01:59 -0000	1.4.2.1
+++ lib/test/unit/collector/dir.rb	5 Jan 2005 04:05:53 -0000
@@ -75,7 +75,6 @@
         end
 
         def collect_file(name, suites, already_gathered)
-          loadpath = $:.dup
           dir = File.dirname(File.expand_path(name))
           $:.unshift(dir) unless $:.first == dir
           if(@req)
@@ -85,7 +84,7 @@
           end
           find_test_cases(already_gathered).each{|t| add_suite(suites, t.suite)}
         ensure
-          $:.replace(loadpath)
+          $:.delete_at $:.rindex(dir)
         end
       end
     end

--Apple-Mail-57--96760441
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed



-- 
Eric Hodel - drbrain / segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E  7C11 332A 551C 796C 9F04
--Apple-Mail-57--96760441--

--Apple-Mail-58--96760417
content-type: application/pgp-signature; x-mac-type=70674453;
	name=PGP.sig
content-description: This is a digitally signed message part
content-disposition: inline; filename=PGP.sig
content-transfer-encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iD8DBQFB255nMypVHHlsnwQRAkyJAJ9yxM3axpstdAXhzyuVPFked4IjugCg5+sb
tWACzyNL2sXx3aC1jorjl9o=
=ZQko
-----END PGP SIGNATURE-----

--Apple-Mail-58--96760417--