Skip to content

Commit

Permalink
non-file tasks now always report current time as timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
jimweirich committed Oct 26, 2012
1 parent bb41014 commit c0482b4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
10 changes: 10 additions & 0 deletions doc/release_notes/rake-10.0.0.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ there are a number of features missing:
* The deprecated <tt>rake/gempackagetask.rb</tt> library has been
removed. Gem supplies its own package task now.

There is one small behavioral change:

* Non-file tasks now always report the current time as their time
stamp. This is different from the previous behavior where non-file
tasks reported current time only if there were no prerequisites, and
the max prerequisite timestamp otherwise. This lead to inconsistent
and surprising behavior when adding prerequisites to tasks that in
turn were prequisites to file tasks. The new behavior is more
consistent and predictable.

== Changes (from 0.9.3)

Since Rake 10 includes the changes from the last version of Rake 9,
Expand Down
2 changes: 1 addition & 1 deletion lib/rake/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def needed?
# Timestamp for this task. Basic tasks return the current time for their
# time stamp. Other tasks can be more sophisticated.
def timestamp
prerequisite_tasks.collect { |pre| pre.timestamp }.max || Time.now
Time.now
end

# Add a description to the task. The description can consist of an option
Expand Down
4 changes: 2 additions & 2 deletions test/test_rake_file_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_file_times_new_depend_on_regular_task_timestamps

task(name => :phony)

assert ! t1.needed?, "unless the non-file task has a timestamp"
assert t1.needed?, "unless the non-file task has a timestamp"
end

def test_file_times_old_depends_on_new
Expand All @@ -83,7 +83,7 @@ def test_file_depends_on_task_depend_on_file

Task[:obj].invoke
Task[NEWFILE].invoke
assert ! @runs.include?(NEWFILE)
assert @runs.include?(NEWFILE)
end

def test_existing_file_depends_on_non_existing_file
Expand Down
2 changes: 1 addition & 1 deletion test/test_rake_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def test_timestamp_returns_latest_prereq_timestamp
def b.timestamp() Time.now + 10 end
def c.timestamp() Time.now + 5 end

assert_in_delta now + 10, a.timestamp, 0.1, 'computer too slow?'
assert_in_delta now, a.timestamp, 0.1, 'computer too slow?'
end

def test_always_multitask
Expand Down

0 comments on commit c0482b4

Please sign in to comment.