From 983815632cc1d316c7c803a47be28f1abe6698fb Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 9 Jun 2010 17:14:47 -0400 Subject: Cut down even further on rake -T noise --- .../lib/active_record/railties/databases.rake | 26 +++++------ railties/lib/rails/tasks/documentation.rake | 47 ++++++++++++++++---- railties/lib/rails/tasks/misc.rake | 4 +- railties/lib/rails/test_unit/testing.rake | 50 ++++++++++++++++------ 4 files changed, 91 insertions(+), 36 deletions(-) diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 6f7e71bfe6..006e64b115 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -5,7 +5,7 @@ namespace :db do end namespace :create do - desc 'Create all the local databases defined in config/database.yml' + # desc 'Create all the local databases defined in config/database.yml' task :all => :load_config do ActiveRecord::Base.configurations.each_value do |config| # Skip entries that don't have a database key, such as the first entry here: @@ -26,7 +26,7 @@ namespace :db do end end - desc 'Create the database defined in config/database.yml for the current Rails.env - also makes test database if in development mode' + desc 'Create the database from config/database.yml for the current Rails.env (use db:create:all to create all dbs in the config)' task :create => :load_config do # Make the test database at the same time as the development one, if it exists if Rails.env.development? && ActiveRecord::Base.configurations['test'] @@ -100,7 +100,7 @@ namespace :db do end namespace :drop do - desc 'Drops all the local databases defined in config/database.yml' + # desc 'Drops all the local databases defined in config/database.yml' task :all => :load_config do ActiveRecord::Base.configurations.each_value do |config| # Skip entries that don't have a database key @@ -115,7 +115,7 @@ namespace :db do end end - desc 'Drops the database for the current Rails.env' + desc 'Drops the database for the current Rails.env (use db:drop:all to drop all databases)' task :drop => :load_config do config = ActiveRecord::Base.configurations[Rails.env || 'development'] begin @@ -142,7 +142,7 @@ namespace :db do end namespace :migrate do - desc 'Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x).' + # desc 'Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x).' task :redo => :environment do if ENV["VERSION"] Rake::Task["db:migrate:down"].invoke @@ -153,10 +153,10 @@ namespace :db do end end - desc 'Resets your database using your migrations for the current environment' + # desc 'Resets your database using your migrations for the current environment' task :reset => ["db:drop", "db:create", "db:migrate"] - desc 'Runs the "up" for a given migration VERSION.' + # desc 'Runs the "up" for a given migration VERSION.' task :up => :environment do version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil raise "VERSION is required" unless version @@ -164,7 +164,7 @@ namespace :db do Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby end - desc 'Runs the "down" for a given migration VERSION.' + # desc 'Runs the "down" for a given migration VERSION.' task :down => :environment do version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil raise "VERSION is required" unless version @@ -187,7 +187,7 @@ namespace :db do Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby end - desc 'Drops and recreates the database from db/schema.rb for the current environment and loads the seeds.' + # desc 'Drops and recreates the database from db/schema.rb for the current environment and loads the seeds.' task :reset => [ 'db:drop', 'db:setup' ] # desc "Retrieves the charset for the current environment's database" @@ -240,7 +240,7 @@ namespace :db do end end - desc 'Create the database, load the schema, and initialize with the seed data' + desc 'Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the db first)' task :setup => [ 'db:create', 'db:schema:load', 'db:seed' ] desc 'Load the seed data from db/seeds.rb' @@ -263,7 +263,7 @@ namespace :db do end end - desc "Search for a fixture given a LABEL or ID. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures." + # desc "Search for a fixture given a LABEL or ID. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures." task :identify => :environment do require 'active_record/fixtures' @@ -347,7 +347,7 @@ namespace :db do end namespace :test do - desc "Recreate the test database from the current schema.rb" + # desc "Recreate the test database from the current schema.rb" task :load => 'db:test:purge' do ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test']) ActiveRecord::Schema.verbose = false @@ -391,7 +391,7 @@ namespace :db do end end - desc "Empty the test database" + # desc "Empty the test database" task :purge => :environment do abcs = ActiveRecord::Base.configurations case abcs["test"]["adapter"] diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index c7de6783a7..492f05e3cc 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -1,13 +1,43 @@ require 'rake/rdoctask' +# Monkey-patch to remove redoc'ing and clobber descriptions to cut down on rake -T noise +class RDocTaskWithoutDescriptions < Rake::RDocTask + def define + task rdoc_task_name + + task rerdoc_task_name => [clobber_task_name, rdoc_task_name] + + task clobber_task_name do + rm_r rdoc_dir rescue nil + end + + task :clobber => [clobber_task_name] + + directory @rdoc_dir + task rdoc_task_name => [rdoc_target] + file rdoc_target => @rdoc_files + [Rake.application.rakefile] do + rm_r @rdoc_dir rescue nil + @before_running_rdoc.call if @before_running_rdoc + args = option_list + @rdoc_files + if @external + argstring = args.join(' ') + sh %{ruby -Ivendor vendor/rd #{argstring}} + else + require 'rdoc/rdoc' + RDoc::RDoc.new.document(args) + end + end + self + end +end + namespace :doc do def gem_path(gem_name) path = $LOAD_PATH.grep(/#{gem_name}[\w.-]*\/lib$/).first yield File.dirname(path) if path end - desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\"" - Rake::RDocTask.new("app") { |rdoc| + RDocTaskWithoutDescriptions.new("app") { |rdoc| rdoc.rdoc_dir = 'doc/app' rdoc.template = ENV['template'] if ENV['template'] rdoc.title = ENV['title'] || "Rails Application Documentation" @@ -17,9 +47,10 @@ namespace :doc do rdoc.rdoc_files.include('app/**/*.rb') rdoc.rdoc_files.include('lib/**/*.rb') } + Rake::Task['doc:app'].comment = "Generate docs for the app -- also availble doc:rails, doc:guides, doc:plugins (options: TEMPLATE=/rdoc-template.rb, TITLE=\"Custom Title\")" - desc 'Generate documentation for the Rails framework.' - Rake::RDocTask.new("rails") { |rdoc| + # desc 'Generate documentation for the Rails framework.' + RDocTaskWithoutDescriptions.new("rails") { |rdoc| rdoc.rdoc_dir = 'doc/api' rdoc.template = "#{ENV['template']}.rb" if ENV['template'] rdoc.title = "Rails Framework Documentation" @@ -71,15 +102,15 @@ namespace :doc do plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) } - desc "Generate documentation for all installed plugins" + # desc "Generate documentation for all installed plugins" task :plugins => plugins.collect { |plugin| "doc:plugins:#{plugin}" } - desc "Remove plugin documentation" + # desc "Remove plugin documentation" task :clobber_plugins do rm_rf 'doc/plugins' rescue nil end - desc "Generate Rails Guides" + # desc "Generate Rails Guides" task :guides do # FIXME: Reaching outside lib directory is a bad idea require File.expand_path('../../../../guides/rails_guides', __FILE__) @@ -89,7 +120,7 @@ namespace :doc do namespace :plugins do # Define doc tasks for each plugin plugins.each do |plugin| - desc "Generate documentation for the #{plugin} plugin" + # desc "Generate documentation for the #{plugin} plugin" task(plugin => :environment) do plugin_base = "vendor/plugins/#{plugin}" options = [] diff --git a/railties/lib/rails/tasks/misc.rake b/railties/lib/rails/tasks/misc.rake index 09c8a1a223..c6c22d83bf 100644 --- a/railties/lib/rails/tasks/misc.rake +++ b/railties/lib/rails/tasks/misc.rake @@ -7,13 +7,13 @@ task :rails_env do end end -desc 'Generate a crytographically secure secret key (rhis is typically used to generate a secret for cookie sessions).' +desc 'Generate a crytographically secure secret key (this is typically used to generate a secret for cookie sessions).' task :secret do require 'active_support/secure_random' puts ActiveSupport::SecureRandom.hex(64) end -desc 'Explain the current environment' +desc 'List versions of all Rails frameworks and the environment' task :about do puts Rails::Info end diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake index 79fa667ed1..4bddf7600a 100644 --- a/railties/lib/rails/test_unit/testing.rake +++ b/railties/lib/rails/test_unit/testing.rake @@ -1,5 +1,35 @@ require 'rake/testtask' +# Monkey-patch to silence the description from Rake::TestTask to cut down on rake -T noise +class TestTaskWithoutDescription < Rake::TestTask + # Create the tasks defined by this task lib. + def define + lib_path = @libs.join(File::PATH_SEPARATOR) + task @name do + run_code = '' + RakeFileUtils.verbose(@verbose) do + run_code = + case @loader + when :direct + "-e 'ARGV.each{|f| load f}'" + when :testrb + "-S testrb #{fix}" + when :rake + rake_loader + end + @ruby_opts.unshift( "-I\"#{lib_path}\"" ) + @ruby_opts.unshift( "-w" ) if @warning + ruby @ruby_opts.join(" ") + + " \"#{run_code}\" " + + file_list.collect { |fn| "\"#{fn}\"" }.join(' ') + + " #{option_list}" + end + end + self + end +end + + TEST_CHANGES_SINCE = Time.now - 600 # Look up tests for recently modified sources. @@ -40,7 +70,7 @@ module Kernel end end -desc 'Run all unit, functional and integration tests' +desc 'Runs test:unit, test:functional, test:integration together (also available: test:benchmark, test:profile, test:plugins)' task :test do errors = %w(test:units test:functionals test:integration).collect do |task| begin @@ -92,38 +122,33 @@ namespace :test do end Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion and Git)" - Rake::TestTask.new(:units => "test:prepare") do |t| + TestTaskWithoutDescription.new(:units => "test:prepare") do |t| t.libs << "test" t.pattern = 'test/unit/**/*_test.rb' end - Rake::Task['test:units'].comment = "Run the unit tests in test/unit" - Rake::TestTask.new(:functionals => "test:prepare") do |t| + TestTaskWithoutDescription.new(:functionals => "test:prepare") do |t| t.libs << "test" t.pattern = 'test/functional/**/*_test.rb' end - Rake::Task['test:functionals'].comment = "Run the functional tests in test/functional" - Rake::TestTask.new(:integration => "test:prepare") do |t| + TestTaskWithoutDescription.new(:integration => "test:prepare") do |t| t.libs << "test" t.pattern = 'test/integration/**/*_test.rb' end - Rake::Task['test:integration'].comment = "Run the integration tests in test/integration" - Rake::TestTask.new(:benchmark => 'test:prepare') do |t| + TestTaskWithoutDescription.new(:benchmark => 'test:prepare') do |t| t.libs << 'test' t.pattern = 'test/performance/**/*_test.rb' t.options = '-- --benchmark' end - Rake::Task['test:benchmark'].comment = 'Benchmark the performance tests' - Rake::TestTask.new(:profile => 'test:prepare') do |t| + TestTaskWithoutDescription.new(:profile => 'test:prepare') do |t| t.libs << 'test' t.pattern = 'test/performance/**/*_test.rb' end - Rake::Task['test:profile'].comment = 'Profile the performance tests' - Rake::TestTask.new(:plugins => :environment) do |t| + TestTaskWithoutDescription.new(:plugins => :environment) do |t| t.libs << "test" if ENV['PLUGIN'] @@ -132,5 +157,4 @@ namespace :test do t.pattern = 'vendor/plugins/*/**/test/**/*_test.rb' end end - Rake::Task['test:plugins'].comment = "Run the plugin tests in vendor/plugins/*/**/test (or specify with PLUGIN=name)" end -- cgit v1.2.3