Skip to content

Commit

Permalink
Merge pull request #327 from mjbellantoni/mjb-order-only-arg-fix
Browse files Browse the repository at this point in the history
Fix an incorrectly resolved arg pattern
  • Loading branch information
hsbt committed Nov 12, 2019
2 parents 4a90acb + 46a8f7c commit 985abff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/rake/task_manager.rb
Expand Up @@ -83,8 +83,8 @@ def synthesize_file_task(task_name) # :nodoc:
define_task(Rake::FileTask, task_name)
end

# Resolve the arguments for a task/rule. Returns a triplet of
# [task_name, arg_name_list, prerequisites].
# Resolve the arguments for a task/rule. Returns a tuple of
# [task_name, arg_name_list, prerequisites, order_only_prerequisites].
def resolve_args(args)
if args.last.is_a?(Hash)
deps = args.pop
Expand Down Expand Up @@ -118,8 +118,11 @@ def resolve_args_without_dependencies(args)
#
# The patterns recognized by this argument resolving function are:
#
# task :t, order_only: [:e]
# task :t => [:d]
# task :t => [:d], order_only: [:e]
# task :t, [a] => [:d]
# task :t, [a] => [:d], order_only: [:e]
#
def resolve_args_with_dependencies(args, hash) # :nodoc:
fail "Task Argument Error" if
Expand All @@ -133,8 +136,8 @@ def resolve_args_with_dependencies(args, hash) # :nodoc:
deps = value || []
else
task_name = args.shift
arg_names = key
deps = value
arg_names = key || args.shift|| []
deps = value || []
end
deps = [deps] unless deps.respond_to?(:to_ary)
[task_name, arg_names, deps, order_only]
Expand Down
7 changes: 7 additions & 0 deletions test/test_rake_task_manager_argument_resolution.rb
Expand Up @@ -8,9 +8,16 @@ def test_good_arg_patterns
assert_equal [:t, [], [:x], nil], task(t: :x)
assert_equal [:t, [], [:x, :y], nil], task(t: [:x, :y])

assert_equal [:t, [], [], [:m]], task(:t, order_only: [:m])
assert_equal [:t, [], [:x, :y], [:m, :n]], task(t: [:x, :y], order_only: [:m, :n])

assert_equal [:t, [:a, :b], [], nil], task(:t, [:a, :b])
assert_equal [:t, [:a, :b], [:x], nil], task(:t, [:a, :b] => :x)
assert_equal [:t, [:a, :b], [:x, :y], nil], task(:t, [:a, :b] => [:x, :y])

assert_equal [:t, [:a, :b], [], [:m]], task(:t, [:a, :b], order_only: [:m])
assert_equal [:t, [:a, :b], [:x], [:m]], task(:t, [:a, :b] => :x, order_only: [:m])
assert_equal [:t, [:a, :b], [:x, :y], [:m, :n]], task(:t, [:a, :b] => [:x, :y], order_only: [:m, :n])
end

def task(*args)
Expand Down

0 comments on commit 985abff

Please sign in to comment.