Forum: Ruby Running rake silently ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Nuno (Guest)
on 2006-04-06 15:33
Hi, may be I'm a bit off topic here but... Is there a way to run rake
silently ? --silent, -s, --quiet don't have any effect and when I use
rake for testing purpose the output is polluted with unecessary
informations.

I only need the results of the tests, and of course the file/line in
case of error or test failure

eg.

[chris@aboulafia login_engine]$ rake -s
/usr/bin/ruby -Ilib:lib
"/usr/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake/rake_test_loader.rb"
"test/unit/login_engine_test.rb"
-- create_table("accounts", {:force=>true})
   -> 0.0590s
-- create_table("articles", {:force=>true})
   -> 0.0084s
-- create_table("categories", {:force=>true})
   -> 0.0133s
-- create_table("comments", {:force=>true})
   -> 0.0107s
-- create_table("contacts", {:force=>true})
   -> 0.0079s
-- create_table("engine_schema_info", {:id=>false, :force=>true})
   -> 0.0305s
-- create_table("images", {:force=>true})
   -> 0.0091s
-- initialize_schema_information()
   -> 0.0020s
-- columns("schema_info")
   -> 0.0011s
Loaded suite
/usr/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake/rake_test_loader
Started
..
Finished in 0.026826 seconds.

2 tests, 6 assertions, 0 failures, 0 errors


Thanks
Jim W. (Guest)
on 2006-04-06 16:14
Nuno wrote:
> Hi, may be I'm a bit off topic here but... Is there a way to run rake
> silently ? --silent, -s, --quiet don't have any effect and when I use
> rake for testing purpose the output is polluted with unecessary
> informations.
>
> I only need the results of the tests, and of course the file/line in
> case of error or test failure

Most of the output is generated by software other than rake, so is
outside the control of rake itself.

> [chris@aboulafia login_engine]$ rake -s
> /usr/bin/ruby -Ilib:lib
> "/usr/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake/rake_test_loader.rb"
> "test/unit/login_engine_test.rb"

The above three lines (probably only one line prior to pasting) can be
silenced by setting verbose to false in the test task.  E.g.

  Rake:TestTask.new("whatever") do |t|
    t.verbose = false     # ADD THIS LINE
    ... # whatever else you have
  end

> -- create_table("accounts", {:force=>true})
>    -> 0.0590s
> -- create_table("articles", {:force=>true})
>    -> 0.0084s
> -- create_table("categories", {:force=>true})
>    -> 0.0133s
> -- create_table("comments", {:force=>true})
>    -> 0.0107s
> -- create_table("contacts", {:force=>true})
>    -> 0.0079s
> -- create_table("engine_schema_info", {:id=>false, :force=>true})
>    -> 0.0305s
> -- create_table("images", {:force=>true})
>    -> 0.0091s
> -- initialize_schema_information()
>    -> 0.0020s
> -- columns("schema_info")
>    -> 0.0011s

These lines looke like they are being created by whatever it is that you
are testing. Maybe some setup code somewhere.

> Loaded suite
> /usr/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake/rake_test_loader
> Started
> ..
> Finished in 0.026826 seconds.
>
> 2 tests, 6 assertions, 0 failures, 0 errors

The above lines are generated by the test suite software itself.  There
are several options in Test::Unit to control this.  And you can always
write your own runner to display whatever you wish.

Hope that helped.

--
-- Jim W.
James A. (Guest)
on 2006-04-06 17:42
(Received via mailing list)
Check out the 'Controlling Verbosity' section on this page:
http://api.rubyonrails.com/classes/ActiveRecord/Mi...

Basically you want to set this in your environment.rb

- james
James G. (Guest)
on 2006-04-06 17:45
(Received via mailing list)
On Apr 6, 2006, at 7:14 AM, Jim W. wrote:

>> -- create_table("engine_schema_info", {:id=>false, :force=>true})
> are testing. Maybe some setup code somewhere.
This is output from the `rake migrate` task in the latest version of
Rails, just FYI.

James Edward G. II
Nuno (Guest)
on 2006-04-07 15:08
James G. wrote:
> On Apr 6, 2006, at 7:14 AM, Jim W. wrote:
>
>>> -- create_table("engine_schema_info", {:id=>false, :force=>true})
>> are testing. Maybe some setup code somewhere.
> This is output from the `rake migrate` task in the latest version of
> Rails, just FYI.
>
> James Edward G. II

Thanks for your answers ! rake outputs produced by rails rakefiles are
still verbose but at least I understand why ;-)
This topic is locked and can not be replied to.