Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an incorrectly resolved arg pattern #327

Merged
merged 2 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lib/rake/task_manager.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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