Skip to content

Commit

Permalink
Merge pull request #350 from jasonkarns/rule-prereq-symbol
Browse files Browse the repository at this point in the history
rule learns to accept Symbols as a prereq name
  • Loading branch information
hsbt committed Apr 23, 2021
2 parents a842fb2 + 6a82435 commit fc688bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rake/task_manager.rb
Expand Up @@ -300,8 +300,8 @@ def make_sources(task_name, task_pattern, extensions)
when /^\./
source = task_name.sub(task_pattern, ext)
source == ext ? task_name.ext(ext) : source
when String
ext
when String, Symbol
ext.to_s
when Proc, Method
if ext.arity == 1
ext.call(task_name)
Expand Down
11 changes: 11 additions & 0 deletions test/test_rake_rules.rb
Expand Up @@ -80,6 +80,17 @@ def test_rule_prereqs_can_be_created_by_string
assert_equal [OBJFILE], @runs
end

def test_rule_prereqs_can_be_created_by_symbol
task :nonfile do |t|
@runs << t.name
end
rule ".o" => :nonfile do |t|
@runs << t.name
end
Task[OBJFILE].invoke
assert_equal ["nonfile", OBJFILE], @runs
end

def test_plain_strings_as_dependents_refer_to_files
create_file(SRCFILE)
rule ".o" => SRCFILE do |t|
Expand Down

0 comments on commit fc688bd

Please sign in to comment.