Skip to content

Commit

Permalink
Accept Pathname-like object as rule's prerequisite
Browse files Browse the repository at this point in the history
  • Loading branch information
gemmaro committed Dec 15, 2023
1 parent b29fb4e commit fe0b1ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/rake/task_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,11 @@ def make_sources(task_name, task_pattern, extensions)
ext.call
end
else
fail "Don't know how to handle rule dependent: #{ext.inspect}"
if (ext = Rake.from_pathname(ext)).is_a?(String)
ext
else
fail "Don't know how to handle rule dependent: #{ext.inspect}"
end
end
}
result.flatten
Expand Down
10 changes: 10 additions & 0 deletions test/test_rake_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ def test_rule_prereqs_can_be_created_by_string
assert_equal [OBJFILE], @runs
end

def test_rule_prereqs_can_be_created_by_pathname
create_file(SRCFILE)
create_file(FOOFILE)
rule ".o" => [".c", Pathname(FOOFILE)] do |t|
@runs << t.name
end
Task[OBJFILE].invoke
assert_equal [OBJFILE], @runs
end

def test_rule_prereqs_can_be_created_by_symbol
task :nonfile do |t|
@runs << t.name
Expand Down

0 comments on commit fe0b1ba

Please sign in to comment.