Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Ruby Gem Creates Broken Batch File for Rake

Reply
Thread Tools

Ruby Gem Creates Broken Batch File for Rake

 
 
Bret Pettichord
Guest
Posts: n/a
 
      04-10-2007
Recently I have been integrating Rake with Nant. Specifically, I have
been creating Nant tasks that trigger Rake. In the process of doing
this, I have run into a problem: namely when Rake fails, Nant thinks
that it succeeds. I have tracked down the problem to the Rake batch
file, apparently created by the Gem system, that is used to invoke
Rake.

The problem is that the return code (which is 1, failure) returned
from the
Ruby process is not propagated by the Rake batch file. Nant thus sees
a return code of 0 (success). I have worked around this problem by not
using the Rake batch file and invoking ruby.exe directly. However, it
seems to me that others may also run into this problem, and also that
the Gem batch file generation system could be fixed. I suspect this
problem could also affect other gems besides Rake.

Here is my original Nant task, which did not correctly report Rake
failures:

<property name="rake" value="C:\ruby\bin\rake.bat" />
<target name="_ui-tests">
<exec program="${rake}" workingdir="${watir-tests.dir}"
verbose="true">
<arg value="ci:setup:testunit" />
<arg value="test" />
</exec>
</target>

Here is my corrected Nant task:

<property name="ruby" value="C:\ruby\bin\ruby.exe" />
<property name="rake" value="C:\ruby\bin\rake.bat" />
<target name="_ui-tests">
<exec program="${ruby}" workingdir="${watir-tests.dir}"
verbose="true">
<arg value="-x" />
<arg value="${rake}" />
<arg value="ci:setup:testunit" />
<arg value="test" />
</exec>
</target>

Here is some information from CC.Net (which I am also using) that I
used to help debug return codes (aka error levels) on Windows:

http://confluence.public.thoughtwork...play/CCNET/FAQ
See "CruiseControl.NET is reporting that the build succeeded when it
failed. Why?"

A collegue suggested that I directly modify the batch file, but since
it seems to be autogenerated by Rake, and it doesn't seem to actually
be doing very much (I turned "@echo on" to see what it was doing), I
figured it would be easier to simply avoid using it.

I would appreciate comments and alternate suggestions.

Bret

Bret Pettichord, www.pettichord.com
Lead Developer, Watir, http://wtr.rubyforge.org
Test Architect, Dovetail, www.dovetailsoftware.com

 
Reply With Quote
 
 
 
 
Alexey Verkhovsky
Guest
Posts: n/a
 
      04-10-2007
On 4/10/07, Bret Pettichord <(E-Mail Removed)> wrote:
> figured it would be easier to simply avoid using it.


We figured out as much in the course of CruiseControl.rb project.
Have a look at Build#rake() method in app/models/build.rb of that code base.

--
Alex Verkhovsky

 
Reply With Quote
 
 
 
 
Alexey Verkhovsky
Guest
Posts: n/a
 
      04-10-2007
On 4/10/07, Bret Pettichord <(E-Mail Removed)> wrote:
> def rake
> # --nosearch flag here prevents CC.rb from building itself when a
> project has no Rakefile
> %{ruby -e "require 'rubygems' rescue nil; require 'rake'; load '#{
> File.expand_path(RAILS_ROOT)}/tasks/cc_build.rake'; ARGV <<
> '--nosearch'#{CruiseControl::Log.verbose? ? " << '--trace'" : ""} <<
> 'cc:build'; Rake.application.run"}
> end


Ugly, isn't it?

Alex

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mkmf creates broken makefile (Windows) ZippySwish Ruby 2 12-23-2008 01:23 AM
Rake TestTask running its block anytime rake is invoked Adam Anderson Ruby 1 09-19-2007 08:40 AM
Rake and rake aborted! Rake aborted! undefined method `gem' for main:Object peppermonkey Ruby 1 02-10-2007 04:43 AM
RubyGems 0.9.1 calling a gem with gem '<gem>' Austin 7873 Ruby 5 01-27-2007 10:05 PM
Rake 0.7.0 breaks "rake engine_migrate"? Joe Van Dyk Ruby 2 01-31-2006 12:11 AM



Advertisments