diff --git a/lib/rake/file_task.rb b/lib/rake/file_task.rb index c36b49699..fbaf10374 100644 --- a/lib/rake/file_task.rb +++ b/lib/rake/file_task.rb @@ -34,14 +34,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 } end # ---------------------------------------------------------------- diff --git a/lib/rake/task.rb b/lib/rake/task.rb index ec2c756e0..839351346 100644 --- a/lib/rake/task.rb +++ b/lib/rake/task.rb @@ -216,7 +216,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 diff --git a/test/test_rake_functional.rb b/test/test_rake_functional.rb index afc31d28f..db5079d23 100644 --- a/test/test_rake_functional.rb +++ b/test/test_rake_functional.rb @@ -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