Skip to content

Commit 985abff

Browse files
authoredNov 12, 2019
Merge pull request #327 from mjbellantoni/mjb-order-only-arg-fix
Fix an incorrectly resolved arg pattern
2 parents 4a90acb + 46a8f7c commit 985abff

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed
 

‎lib/rake/task_manager.rb

+7-4
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ def synthesize_file_task(task_name) # :nodoc:
8383
define_task(Rake::FileTask, task_name)
8484
end
8585

86-
# Resolve the arguments for a task/rule. Returns a triplet of
87-
# [task_name, arg_name_list, prerequisites].
86+
# Resolve the arguments for a task/rule. Returns a tuple of
87+
# [task_name, arg_name_list, prerequisites, order_only_prerequisites].
8888
def resolve_args(args)
8989
if args.last.is_a?(Hash)
9090
deps = args.pop
@@ -118,8 +118,11 @@ def resolve_args_without_dependencies(args)
118118
#
119119
# The patterns recognized by this argument resolving function are:
120120
#
121+
# task :t, order_only: [:e]
121122
# task :t => [:d]
123+
# task :t => [:d], order_only: [:e]
122124
# task :t, [a] => [:d]
125+
# task :t, [a] => [:d], order_only: [:e]
123126
#
124127
def resolve_args_with_dependencies(args, hash) # :nodoc:
125128
fail "Task Argument Error" if
@@ -133,8 +136,8 @@ def resolve_args_with_dependencies(args, hash) # :nodoc:
133136
deps = value || []
134137
else
135138
task_name = args.shift
136-
arg_names = key
137-
deps = value
139+
arg_names = key || args.shift|| []
140+
deps = value || []
138141
end
139142
deps = [deps] unless deps.respond_to?(:to_ary)
140143
[task_name, arg_names, deps, order_only]

‎test/test_rake_task_manager_argument_resolution.rb

+7
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@ def test_good_arg_patterns
88
assert_equal [:t, [], [:x], nil], task(t: :x)
99
assert_equal [:t, [], [:x, :y], nil], task(t: [:x, :y])
1010

11+
assert_equal [:t, [], [], [:m]], task(:t, order_only: [:m])
12+
assert_equal [:t, [], [:x, :y], [:m, :n]], task(t: [:x, :y], order_only: [:m, :n])
13+
1114
assert_equal [:t, [:a, :b], [], nil], task(:t, [:a, :b])
1215
assert_equal [:t, [:a, :b], [:x], nil], task(:t, [:a, :b] => :x)
1316
assert_equal [:t, [:a, :b], [:x, :y], nil], task(:t, [:a, :b] => [:x, :y])
17+
18+
assert_equal [:t, [:a, :b], [], [:m]], task(:t, [:a, :b], order_only: [:m])
19+
assert_equal [:t, [:a, :b], [:x], [:m]], task(:t, [:a, :b] => :x, order_only: [:m])
20+
assert_equal [:t, [:a, :b], [:x, :y], [:m, :n]], task(:t, [:a, :b] => [:x, :y], order_only: [:m, :n])
1421
end
1522

1623
def task(*args)

0 commit comments

Comments
 (0)
Please sign in to comment.