[Rake-devel] Fix for infinite loop bug

Daniel Berger djberge at qwest.com
Mon May 2 12:22:45 EDT 2005

Hi all,

The following change fixes the infinite loop on Win32 systems.  The 
logic is simple - if the dir length is the same in two iterations, it 
means we've reached the "root" directory and it's not going to get any 

--- rake.orig   Mon May  2 09:25:51 2005
+++ rake.rb     Mon May  2 09:36:16 2005
@@ -406,10 +406,12 @@
  #   directory "testdata/doc"
  def directory(dir)
-  while dir != '.' && dir != '/'
+  old_length = nil
+  while dir != '.' && dir.length != old_length
      file dir do |t|
        mkdir_p t.name if ! File.exist?(t.name)
+    old_length = dir.length
      dir = File.dirname(dir)

I ran testtasks.rb on Solaris after this to make sure it worked:

 >ruby test/testtasks.rb
Loaded suite test/testtasks
Finished in 3.564708 seconds.

   1) Failure:
test_create(TestTask) [test/testtasks.rb:19]:
<false> is not true.

29 tests, 66 assertions, 1 failures, 0 errors

The failure you see occurs with or without this change, so it's 
unrelated.  The test in question is:

assert t.prerequisites.is_a?(FileList)

I haven't provided any test cases yet because it appears there are still 
other places where rake.rb goes into an infinite loop (running 
testtasks.rb confirms this).  I think it's coming from 
create_timed_files atm.

I'll patch 'em as I see 'em.



More information about the Rake-devel mailing list