|
Subject: Re: 0.14.2 Rake task override ? Newsgroups: gmane.comp.lang.ruby.rails Date: 2005-10-31 05:26:18 GMT (2 years, 27 weeks, 4 days, 14 hours and 7 minutes ago)
Peter Fitzgibbons wrote:
> Hello all,
>
> I have a rails app using legacy MSSQL db that is 1.5Gb... so running
> :prepare_test_database on every test run is very very painful on
> front-loaded processing time.
> In 0.13.1 I edited the rake tasks to make :test_units and
> :test_functional depend only on :environment... I am responsible for
> running :clone_to_test_db on my own.
>
> How can I override the 0.14.2 rake tasks :test_units and
> :test_functional in only my one project?
>
> Thanks.
Hello,
I put the code at the bottom of this message into a new file named
'lib/tasks/000_redefine_task.rake' and then I would create another file
named 'lib/tasks/my_tests.rake' or something like that and does this:
redefine_task :test_units => :environment
Rake::TestTask.new(:test_units) do |t|
t.libs << "test"
t.pattern = 'test/unit/**/*_test.rb'
t.verbose = true
end
redefine_task :test_units => ::environment
Rake::TestTask.new(:test_functional) do |t|
t.libs << "test"
t.pattern = 'test/functional/**/*_test.rb'
t.verbose = true
end
BTW, if this doesn't work, you may need to apply this patch to RoR,
which is now in trunk:
$ svn diff -r 2739:2740
Index: railties/lib/tasks/rails.rb
===================================================================
--- railties/lib/tasks/rails.rb (revision 2739)
+++ railties/lib/tasks/rails.rb (revision 2740)
@@ -4,5 +4,5 @@
Dir["#{File.dirname(__FILE__)}/*.rake"].each { |ext| load ext }
# Load any custom rakefile extensions
-Dir["./lib/tasks/**/*.rake"].each { |ext| load ext }
-Dir["./vendor/plugins/*/tasks/**/*.rake"].each { |ext| load ext }
\ No newline at end of file
+Dir["./lib/tasks/**/*.rake"].sort.each { |ext| load ext }
+Dir["./vendor/plugins/*/tasks/**/*.rake"].sort.each { |ext| load ext }
\ No newline at end of file
Regards,
Blair
--
Blair Zajac, Ph.D.
<blair@...>
Subversion and Orca training and consulting
http://www.orcaware.com/svn/
# Rake allows the same task name to be specified multiple times, where
# each successive task definition appends to a list of actions to
# perform. Therefore, an application specific task cannot redefine a
# previously defined task. These methods here allow tasks to be
# redefined and renamed.
module Rake
class Task
# Clear all existing actions for the given task and then set the
# action for the task to the given block.
def self.redefine_task(args, &block)
task_name, deps = resolve_args(args)
TASKS.delete(task_name.to_s)
define_task(args, &block)
end
end
end
# Clear all existing actions for the given task and then set the
# action for the task to the given block.
def redefine_task(args, &block)
Rake::Task.redefine_task(args, &block)
end
# Alias one task name to another task name. This let's a following
# task rename the original task and still depend upon it.
def alias_task(new_name, old_name)
Rake::Task::TASKS[new_name.to_s] =
Rake::Task::TASKS.delete(old_name.to_s)
end
|
|
|