> Programming Languages > Ruby
Various Topics Home | Disclaimer | Report Adult Posts

Various Topics on Ruby



Ruby - "Rake desc bug" in Programming Languages


Old 06-21-2004   #1
..m ..na..
 
Default Rake desc bug

I think I've found a minor bug in Rake with the "desc" method and -T flag.

task :default => [ne]

task ne do
puts 'one'
end

desc "description of task one"
task ne => [:anything]

desc "description of task two"
task :two do
puts 'two'
end

% rake -T
(in c:/jmenard)
rake two # description of task two

This only happens if "task ne" appears more than once and the description
comes after the first "task ne". For example, reversing the tasks but
keeping the desc after the second one does the same thing:

task :default => [ne]

task ne do
puts 'one'
end

desc "description of task one"
task ne => [:anything]

desc "description of task two"
task :two do
puts 'two'
end

% rake -T
(in c:/jmenard)
rake two # description of task two

If I move the desc up before the first "task ne" then both descriptions get
printed:

task :default => [ne]

desc "description of task one"
task ne => [:anything]

task ne do
puts 'one'
end

desc "description of task two"
task :two do
puts 'two'
end

~> rake -T
(in c:/jmenard)
rake one # description of task one
rake two # description of task two

Looking at rake.rb, I think the problem is that $last_comment is only used
when a new task is created, not when an existing one is extended (re-opened?
added to?). I don't know if using $last_comment inside Task.define_task
instead of in the initialize method makes sense or if that would break
something else.

Jim
--
Jim Menard, jimm@io.com, http://www.io.com/~jimm/
"Yeah, well, don't count your weasels before they pop, dink." -- The Tick


 
Old 06-21-2004   #2
..m ..iri..
 
Default Re: Rake desc bug


Jim Menard said:
> I think I've found a minor bug in Rake with the "desc" method and -T flag.
>
> task :default => [ne]
>
> task ne do
> puts 'one'
> end
>
> desc "description of task one"
> task ne => [:anything]
>
> desc "description of task two"
> task :two do
> puts 'two'
> end
>
> % rake -T
> (in c:/jmenard)
> rake two # description of task two
>
> This only happens if "task ne" appears more than once and the
> description
> comes after the first "task ne". For example, reversing the tasks but
> keeping the desc after the second one does the same thing:
>
> task :default => [ne]
>
> task ne do
> puts 'one'
> end
>
> desc "description of task one"
> task ne => [:anything]
>
> desc "description of task two"
> task :two do
> puts 'two'
> end
>
> % rake -T
> (in c:/jmenard)
> rake two # description of task two
>
> If I move the desc up before the first "task ne" then both descriptions
> get
> printed:
>
> task :default => [ne]
>
> desc "description of task one"
> task ne => [:anything]
>
> task ne do
> puts 'one'
> end
>
> desc "description of task two"
> task :two do
> puts 'two'
> end
>
> ~> rake -T
> (in c:/jmenard)
> rake one # description of task one
> rake two # description of task two
>
> Looking at rake.rb, I think the problem is that $last_comment is only used
> when a new task is created, not when an existing one is extended
> (re-opened?
> added to?). I don't know if using $last_comment inside Task.define_task
> instead of in the initialize method makes sense or if that would break
> something else.


Thanks for the report. I think this is a case where it works as designed,
but perhaps it could have been designed better.

I think moving the check for $last_comment should be safe. I'll look at
the code tonight when I get home.

With that in mind, what should rake -T display for the following?

desc "First Comment"
task ne

desc "Second Comment"
task ne

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)



 
Old 06-21-2004   #3
..m ..na..
 
Default Re: Rake desc bug

Jim,

> Thanks for the report. I think this is a case where it works as designed,
> but perhaps it could have been designed better.
>
> I think moving the check for $last_comment should be safe. I'll look at
> the code tonight when I get home.
>
> With that in mind, what should rake -T display for the following?
>
> desc "First Comment"
> task ne
>
> desc "Second Comment"
> task ne


A warning, perhaps?

I can see arguments for keeping the first, the second, or both. I think I'd
prefer seeing both joined by a space.

Thanks for listening.

Jim
--
Jim Menard, jimm@io.com, http://www.io.com/~jimm/
DataVision, the Open Source report designer. http://datavision.sourceforge.net


 
Old 06-22-2004   #4
..m ..iri..
 
Default Re: Rake desc bug

Jim Weirich wrote:
> Jim Menard said:
>>Looking at rake.rb, I think the problem is that $last_comment is only used
>>when a new task is created, not when an existing one is extended
>>(re-opened? added to?).


The latest rake in CVS now supports additive comments. Multiple
comments will be separated by a "/". This feature will be in the next
version.

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)



 

Thread Tools
Display Modes





Powered by vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0