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

rule learns to accept Symbols as a prereq name #350

Merged
merged 1 commit into from
Apr 23, 2021
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
4 changes: 2 additions & 2 deletions lib/rake/task_manager.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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