Skip to content

Commit

Permalink
-m hooked up. test included
Browse files Browse the repository at this point in the history
Added a test for -m in task.rb. Hooked it up.
Concised code in application.rb
Added documentation for -j
  • Loading branch information
michaeljbishop committed Apr 27, 2012
1 parent f40087d commit b828747
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
7 changes: 4 additions & 3 deletions doc/command_line_usage.rdoc
Expand Up @@ -42,14 +42,15 @@ Options are:
value is equal to the number of CPUs.

Sample values:
default: unlimited concurrent tasks (standard rake behavior)
1: one task at a time
no -j : unlimited concurrent tasks (standard rake behavior)
only -j : 2 concurrent tasks
-j 16 : 16 concurrent tasks

[<tt>--libdir</tt> _directory_ (-I)]
Add _directory_ to the list of directories searched for require.

[<tt>--multitask</tt> (-m)]
Treat all tasks as multitasks. ('make' semantics)
Treat all tasks as multitasks. ('make/drake' semantics)

[<tt>--nosearch</tt> (-N)]
Do not search for a Rakefile in parent directories.
Expand Down
4 changes: 1 addition & 3 deletions lib/rake/application.rb
Expand Up @@ -327,9 +327,7 @@ def standard_rake_options
],
['--jobs', '-j [NUMBER]',
"Specifies the maximum number of tasks to execute in parallel. (default:2)",
lambda { |value|
options.thread_pool_size = [(value || 2).to_i,2].max
}
lambda { |value| options.thread_pool_size = [(value || 2).to_i,2].max }
],
['--libdir', '-I LIBDIR', "Include LIBDIR in the search path for required modules.",
lambda { |value| $:.push(value) }
Expand Down
12 changes: 8 additions & 4 deletions lib/rake/task.rb
Expand Up @@ -172,10 +172,14 @@ def add_chain_to(exception, new_chain)

# Invoke all the prerequisites of a task.
def invoke_prerequisites(task_args, invocation_chain) # :nodoc:
prerequisite_tasks.each { |prereq|
prereq_args = task_args.new_scope(prereq.arg_names)
prereq.invoke_with_call_chain(prereq_args, invocation_chain)
}
if application.options.always_multitask
invoke_prerequisites_concurrently(task_args, invocation_chain)
else
prerequisite_tasks.each { |prereq|
prereq_args = task_args.new_scope(prereq.arg_names)
prereq.invoke_with_call_chain(prereq_args, invocation_chain)
}
end
end

def invoke_prerequisites_concurrently(args, invocation_chain)
Expand Down
19 changes: 19 additions & 0 deletions test/test_rake_task.rb
Expand Up @@ -223,6 +223,25 @@ def c.timestamp() Time.now + 5 end
assert_in_delta now + 10, a.timestamp, 0.1, 'computer too slow?'
end

def test_all_multitask
mx = Mutex.new
result = ""
root = task :root
('aa'..'zz').each do |c|
task(c.to_sym) { mx.synchronize{ result << c } }
task(:root => c.to_sym)
end
root.invoke

root.prerequisite_tasks.each { |p| p.reenable };
root.reenable
task_result = result.dup; result.clear

Rake.application.options.always_multitask = true
root.invoke
refute_equal task_result, result
end

def test_investigation_output
t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
task(:t2)
Expand Down

0 comments on commit b828747

Please sign in to comment.