All,
I am making a patch to the rake source and running the tests to verify
that all is ok. Without my changes the tests pass. With my changes I get
a weird error.
42) Error:
test_name_lookup_with_implicit_file_tasks(TestTaskManager):
NoMethodError: undefined method `+@' for
"/home/phelan/ruby/rake/trunk/trunk/test/data":String
./lib/rake.rb:682:in `rel_to_root'
Obviously there is no method "+@" in my code. Has anybody seen this
before? The offending line of code
is
r = File.dirname(r)
looks harmless to me. I've also replaced it with
r = r
and I get the same result.
The patch is below and if anybody can replicate this problem and
understand it it would be great. No need to try and debug my more
general code as that is probably not correct yet anyway. That is why I
am trying to run the tests.
Regards
Brad
$ svn diff -x -w lib/rake.rb
Index: lib/rake.rb
===================================================================
--- lib/rake.rb (revision 609)
+++ lib/rake.rb (working copy)
@@ -667,12 +667,40 @@
# ----------------------------------------------------------------
# Task class methods.
#
+ # Task class methods.
+ #
class << self
# Apply the scope to the task name according to the rules for
this kind
# of task. File based tasks ignore the scope when creating the name.
+ def rel_to_root(*paths)
+ r = Application.root.to_s
+ paths.collect do |p|
+ p = p.to_s
+ n = 0
+ while p.index(r) != 0
+ n++
+ r = File.dirname(r)
+ end
+ prefix = [".."]*n
+ prefix = File.join(*prefix)
+ File.join(prefix, p[r.length+1..-1])
+ end
+ end
def scope_name(scope, task_name)
- task_name
+
+ dir = File.expand_path File.join(Dir.pwd, task_name)
+
+ # puts Application.root
+ # puts Dir.pwd
+ # puts task_name
+ dir = rel_to_root( dir )[0]
+ # puts dir
+ # puts "==="
+ return dir
+
end
+
+
end
end # class Rake::FileTask
@@ -1756,6 +1784,10 @@
class Application
include TaskManager
+ def self.root
+ @@root
+ end
+
# The name of the application (typically 'rake')
attr_reader :name
@@ -2108,6 +2140,9 @@
end
here = Dir.pwd
end
+
+ @@root = here
+
puts "(in #{Dir.pwd})" unless options.silent
$rakefile = @rakefile
load File.expand_path(@rakefile) if @rakefile != ''
_______________________________________________
Rake-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rake-devel