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

[Fixes #246] Don't run file tasks needlessly (2nd attempt) #257

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
9 changes: 1 addition & 8 deletions lib/rake/file_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@ def timestamp

# Are there any prerequisites with a later time than the given time stamp?
def out_of_date?(stamp)
all_prerequisite_tasks.any? { |prereq|
prereq_task = application[prereq, @scope]
if prereq_task.instance_of?(Rake::FileTask)
prereq_task.timestamp > stamp || @application.options.build_all
else
prereq_task.timestamp > stamp
end
}
prerequisite_tasks.any? { |task| task.timestamp > stamp }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’re removing functionality here like the rake --build-all flag and application scoping.

end

# ----------------------------------------------------------------
Expand Down
7 changes: 6 additions & 1 deletion lib/rake/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,12 @@ def invoke_with_call_chain(task_args, invocation_chain)
@already_invoked = true

invoke_prerequisites(task_args, new_chain)
execute(task_args) if needed?

if needed?
execute(task_args)
elsif application.options.dryrun && prerequisite_tasks.any? { |p| p.is_a?(Rake::FileTask) }
application.trace "** Execute (dry run) #{name}"
end
rescue Exception => ex
add_chain_to(ex, new_chain)
@invocation_exception = ex
Expand Down
19 changes: 19 additions & 0 deletions test/test_rake_functional.rb
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,25 @@ def dryrun_tasks
}
end

def test_file_timestamps_respected_despite_task_prerequisite
rakefile <<-RAKEFILE
task "some_task" do
end

file "A" => "some_task"
file "B" => "A" do |t|
touch t.name
end
RAKEFILE

FileUtils.touch("A")
FileUtils.touch("B")

rake "B"

assert(@err !~ /touch B/)
end

def test_update_midway_through_chaining_to_file_task
rakefile_file_chains

Expand Down