Skip to content
Open
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
6 changes: 6 additions & 0 deletions lib/rake/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ def thread_pool # :nodoc:
# Invokes a task with arguments that are extracted from +task_string+
def invoke_task(task_string) # :nodoc:
name, args = parse_task_string(task_string)

if name.end_with?('?') && !lookup(name)
name = name[0..-2]
return unless lookup(name)
end

t = self[name]
t.invoke(*args)
end
Expand Down
23 changes: 23 additions & 0 deletions test/test_rake_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,29 @@ def test_good_run
assert_equal "DEFAULT\n", out
end

def test_safe_run
ran = false
existing_ran = false

@app.options.silent = true

@app.instance_eval do
intern(Rake::Task, "default").enhance { ran = true }
intern(Rake::Task, "existing?").enhance { existing_ran = true }
end

rakefile_default

out, err = capture_output do
@app.run %w[--rakelib="" default existing? missing?]
end

assert ran
assert existing_ran
assert_empty err
assert_equal "DEFAULT\n", out
end

def test_display_task_run
ran = false
@app.last_description = "COMMENT"
Expand Down
Loading